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 |
What do the put and input function do?
is it possible to generate sas datasets using proc print ???
1 Answers GSK GlaxoSmithKline,
Please write codes to merge two datasets and keep every record in the first dataset.
what is portability of sas programmes?
If you need the value of a variable rather than the variable itself what would you use to load the value to a macro variable?
In the SAS Data step what is the difference between the subsetting done by Where and subsetting done by If?
what is sas application server, database server, sas olap server and sas metadata server? : Sas-di
What is the difference between one to one merge and match merge? Give an example.
How does proc sql work?
what are the different ways of merging two datasets.name atleast 4.
Code a PROC SORT on a data set containing State, District and County as the primary variables, along with several numeric variables.
Mention how to limit decimal places for the variable using proc means?