There is a field containing a date. It needs to be
displayed in the format “ddmonyy” if it’s before
1975,”dd
mon ccyy” if it’s after 1985, and as ‘disco years’ if
its
between 1975 and 1985. How would you accomplish this in
data step code? Using only PROC FORMAT.

Answers were Sorted based on User's Feedback



There is a field containing a date. It needs to be displayed in the format “ddmonyy” if it..

Answer / kamalan

proc format;
value datestyl low-'31dec1974'd = [date7.]
'01jan1975'd - '31dec1985'd = 'disco Years'
'01jan1986'd - max = [date9.] ;
Run;

proc print data = abc;
format dateval datestyl.;
Run;

Is This Answer Correct ?    6 Yes 0 No

There is a field containing a date. It needs to be displayed in the format “ddmonyy” if it..

Answer / j. sheetal

Here is the correction in above example,
proc format;
value datestyl low-'31dec1974'd = [date7.]
'01jan1975'd - '31dec1985'd = 'disco Years'
'01jan1986'd - high = [date9.] ;
Run;

Example:

data k1;
input date2 $9.;
cards;
31dec1974
01jan1975
01jan1985
01jan1990
;

data temp;
set k1;
date1=input(date2,date9.);
sam = date1;
format sam datestyl.;
run;

proc print;
run;

Is This Answer Correct ?    4 Yes 0 No

There is a field containing a date. It needs to be displayed in the format “ddmonyy” if it..

Answer / guest

Using the Picture statement Proc Format.

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More SAS Interview Questions

What do the put and input function do?

0 Answers  


is it possible to generate sas datasets using proc print ???

1 Answers   GSK GlaxoSmithKline,


Please write codes to merge two datasets and keep every record in the first dataset.

1 Answers  


what is portability of sas programmes?

2 Answers   Capital One,


If you need the value of a variable rather than the variable itself what would you use to load the value to a macro variable?

2 Answers  






In the SAS Data step what is the difference between the subsetting done by Where and subsetting done by If?

6 Answers   Cognizant,


what is sas application server, database server, sas olap server and sas metadata server? : Sas-di

0 Answers  


What is the difference between one to one merge and match merge? Give an example.

0 Answers  


How does proc sql work?

0 Answers  


what are the different ways of merging two datasets.name atleast 4.

2 Answers  


Code a PROC SORT on a data set containing State, District and County as the primary variables, along with several numeric variables.

7 Answers   Accenture,


Mention how to limit decimal places for the variable using proc means?

0 Answers  


Categories