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
what is a method for assigning first.var and last.var to the by groupvariable on unsorted data? : Sas programming
Difference between informat and format?
Explain data_null_?
what is star schema? : Sas-di
what is sas enterprise intelligence architecture? : Sas-bi
I have a SCD Type 2 Dimention for Location In which A Sales Office in Having two Surrogate Keys just because of the change in it's Sales Group. SKey SalesGroup Sales Office BeginDate EndDate 280 SG1 SO1 01APR2000 01APR2010 281 SG2 SO1 02APR2010 31MAR2999 Now while loading the Fact, the Lookup ir returning SKey 280 for records before and after 01APR2010. I am not able to give WHERE condition in the Lookup Properties (TranDate between BeginDate and EndDate). Please help.
What are all the problems you faced while validating tables and reports?
What is the role of sas grid administrator? : sas-grid-administration
what are the new features included in the new version of sas i.e., Sas 9.1.3? : Sas programming
For what purposes have you used sas macros? : sas-macro
what is the difference between floor and ceil functions in sas? : Sas-administrator
What is the function of output statement in a SAS Program?
how to create the AE dataset by using SDTMIG specifications and SAP plan by using UNIX platform?
name several ways to achieve efficiency in your program? : Sas programming
What are the implications?