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

Which function is used to count the number of intervals between two sas dates?

0 Answers  


what is SAS OPTIMIZATION?

0 Answers  


what is the need of INDEX in datasets?

6 Answers   CitiGroup,


why a stop statement is needed for the point= option on a set statement?

0 Answers  


What is difference between sas rename and lable?

4 Answers  






How would you code a merge that will write the matches of both to one data set, the non-matches from the left-most data set to a second data set, and the non-matches of the right-most data set to a third data set?

2 Answers  


1.What is the difference between _NULL_ , _ALL_, and _N_? 2.What are the uses of _NULL_ using in Data Steps? Can we _NULL_ in Proc Steps also? 3.How do call the macro variable in Data Steps? 4.How to construct Pivot tables in Excel Using SAS?

3 Answers  


What is the use of the %include statement?

0 Answers  


What are some problems you might encounter in processing missing values? In Data steps? Arithmetic? Comparisons? Functions? Classifying data?

1 Answers   Quintiles,


what is option year cuttoff in sas

2 Answers   L&T,


What is a put statement?

0 Answers  


What is difference between rename and lable in sas?

10 Answers   Satyam,






Categories