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


Please Help Members By Posting Answers For Below Questions

How to create an external dataset with sas code?

575


what is hash files in sas and why we are using this one in sas?

1714


Which command is used to perform sorting in sas program?

585


What is substr function?

610


What is the difference between the proc sql and data step?

648






sas implementing companies in pune implementing clinical projects if anyone knows plz send ans immediately

3099


what is the difference between infile and input? : Sas-administrator

599


What is the order of application for output data set options, input data set options and SAS statements?

1071


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

826


what has been your most common programming mistake? : Sas programming

547


What does the trace option do?

652


Tell e how how dealt with..

1757


what are some good sas programming practices for processing very large data sets? : Sas programming

500


how can you create zero observation dataset? : Sas programming

623


I have a dataset concat having a variable a b & c. How to rename a b to e & f?

741