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 are symbol tables?Differemce between Local N Global Symbol tables.....

2 Answers   TCS,


What are the different versions of sas that you have used until now? : sas-grid-administration

0 Answers  


what is scheduling and how will u implement it. In scheduling 5 jobs r running if there is an error occured at 3rd job and how will u check and waht necessary steps will u take not to repeat the same mistake

0 Answers   Blue Star,


%STPbegin;%STPEND; ERROR: No logical assign for filename _WEBOUT. WARNING: No body file. HTML output will not be created. unable to fix it.plz help

2 Answers  


If reading an external file to produce an external file, what is the shortcut to write that record without coding every single variable on the record?

4 Answers  






Hi, If anyone has base SAS certification dumps, please share.

0 Answers  


what kind of variables are collected in AE dataset?

3 Answers   Accenture, Quintiles, SAS,


what is SAS OPTIMIZATION?

0 Answers  


How do you debug macros?

3 Answers   Accenture,


what type of graphs we will create(for 2+years candidates)?

0 Answers   Accenture, Icon,


is data integration and etl programming is same? : Sas-di

0 Answers  


what is intially documentation for a sas programmer?

2 Answers   Accenture,


Categories