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.
Answer Posted / 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 |
Post New Answer View All Answers
How to create an external dataset with sas code?
what is hash files in sas and why we are using this one in sas?
Which command is used to perform sorting in sas program?
What is substr function?
What is the difference between the proc sql and data step?
sas implementing companies in pune implementing clinical projects if anyone knows plz send ans immediately
what is the difference between infile and input? : Sas-administrator
What is the order of application for output data set options, input data set options and SAS statements?
how would you create a data set with 1 observation and 30 variables from a data set with 30 observations and 1 variable? : Sas programming
what has been your most common programming mistake? : Sas programming
What does the trace option do?
Tell e how how dealt with..
what are some good sas programming practices for processing very large data sets? : Sas programming
how can you create zero observation dataset? : Sas programming
I have a dataset concat having a variable a b & c. How to rename a b to e & f?