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

Why is a STOP statement needed for the point=option on a SET statement?

2 Answers   Quintiles,


Name and describe three SAS functions that you have used, if any?

4 Answers   Accenture,


Name statements that are execution only.

4 Answers  


How would you determine how far down on a page you have printed in order to print out footnotes?

3 Answers  


What are common programming errors committed in sas

0 Answers  






What is the one statement to set the criteria of data that can be coded in any step?

4 Answers  


how to read raw data in sas. Do it manually and throw the programming.

1 Answers   WNS,


What does PROC print, and PROC contents do?

0 Answers  


What is the pound sign used for in the data_null_ ?

1 Answers  


How substr function works in sas?

0 Answers  


Are you involved in writing the inferential analysis plan? Tables specfications?

0 Answers  


Briefly describe 5 ways to do a "table lookup" in sas.

4 Answers   Quintiles,






Categories