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
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 |
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 |
Best trainer in hyderabad for sas banking.if any one have details pls provide contact details.
Which command is used to perform sorting in sas program?
You have a data set of 100 observations,how can you restrict the output so that the output has only data from row no. 10 to row no. 20
What is _n_?
How to find out no. of business days in a month using macros.???(excluding weekends and holidays).
What is the difference between an informat and a format? Name three informats or formats.
Given an unsorted data set, how to read the last observation to a new data set?
how to shift the rows to cols? eg: i have like field1 field2 field3 10 20 20 this should be displayed as field1 10 field2 20 field3 30 (without the obs col) how do this?can i use transpose or tell me suitable way to do this?
Difference b/n proc means and proc summary procedures?
Please, anyone, let me know the style or an example of using 'by='/'by' variable of a PDV(Program Data Vector)
3 Answers Verinon Technology Solutions,
What do the put and input function do?
what is the difference btw proc means and proc univariate?