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



There is a field containing a date. It needs to be displayed in the format “ddmonyy” if it..

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

There is a field containing a date. It needs to be displayed in the format “ddmonyy” if it..

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

There is a field containing a date. It needs to be displayed in the format “ddmonyy” if it..

Answer / guest

Using the Picture statement Proc Format.

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More SAS Interview Questions

When merging 2 datasets with a common variable (not merge key), how to keep both?

3 Answers  


what is washout period?

3 Answers   Cognizant,


Where do you use proc means over proc freq?

0 Answers  


hi tell be about pfizer? how to compare the work with other companies ? please tell me how to login and work also?

0 Answers   Pfizer,


How to convert HTML file into SAS dataset?

0 Answers  






in ods is there any lib's

2 Answers   SAS,


What is the purpose of trailing @ and @@? How do you use them?

0 Answers  


What are the functions used for character handling?

0 Answers  


What is program data vector (pdv) and what are its functions?

0 Answers  


HOW DO WE CREATE A SAS STORED PROCESS IN SAS EG ?

1 Answers   TCS,


What are the criticality that you have faced during your project in SAS?

2 Answers  


How can a SAS WEB REPORT STUDIO USER identify which report tabs they have been permitted without entering the SAS WEB REPORT STUDIO

2 Answers   TCS,


Categories