Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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 it's 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" i..

Answer / sudheendra reddy & veerend

DATA D1;
INPUT SLNO DATE DATE7.;
DATALINES;
1 12DEC73
2 22NOV71
3 01JAN76
4 12FEB77
5 13MAR83
6 24APR90
7 17MAY99
;
RUN;

proc format ;
value dat low-'31DEC1974'd=[date7.]
'01JAN1975'd-'31DEC1984'd="Disco Years"
'01JAN1985'd-high=[date9.];
RUN;

proc print data=D1 noobs label;
format DATE dat.;
RUN;

Is This Answer Correct ?    7 Yes 0 No

There is a field containing a date. It needs to be displayed in the format "ddmonyy" i..

Answer / paul

proc format ;
value dat low-'31DEC1974'd=[date7.]
'01JAN1975'd-'31DEC1985'd="Disco Years"
'01JAN1986'd-high=[date9.];
run;

proc sql;
select date format=dat. from D1 ;
quit;

Is This Answer Correct ?    3 Yes 0 No

There is a field containing a date. It needs to be displayed in the format "ddmonyy" i..

Answer / amit gupta

Apologies,
above code has an extra "FROM d1"

The working code is as below:

proc sql;
select
case when date lt '31DEC2006'd then date end as mydate
format=date7. ,
case when date gt '31DEC2008'd then date end as mydate
format=date9. ,
case when '01JAN2007'd <= date <= '31DEC2008'd then 'DUMMY'
end as mydate
from d1 ;
quit;

However it does give the data in 3 columns , which I was
unable to merge as the data type was different.

Any working solution using format ?

Is This Answer Correct ?    1 Yes 0 No

There is a field containing a date. It needs to be displayed in the format "ddmonyy" i..

Answer / amit gupta

proc sql;
select
case when date lt '31DEC2006'd then date end as mydate
format=date7. from d1
case when date gt '31DEC2008'd then date end as mydate
format=date9. ,
case when '01JAN2007'd <= date <= '31DEC2008'd then 'DUMMY'
end as mydate
from d1 ;
quit;


Just that these are in three different columns;

Tried the above resolutions but unsuccessfully.

Is This Answer Correct ?    0 Yes 0 No

There is a field containing a date. It needs to be displayed in the format "ddmonyy" i..

Answer / schuler

data formated(keep=datenew);
length datenew $10.;
set new;
if date<'31dec1974'd then datenew=put(date,date7.);
else if date>'31dec1984'd then datenew=put(date,date7.);
else datenew='Disco Year';
run;
proc print data=formated nobs;run;

Is This Answer Correct ?    0 Yes 0 No

There is a field containing a date. It needs to be displayed in the format "ddmonyy" i..

Answer / sheldon

proc sql;
create table fmtdate(keep=newdate) as
select date,
case
when date lt '31DEC1974'd then put(date,date7.)
when date gt '31DEC1984'd then put(date,date9.)
else 'Desco Year'
end as newdate
from d1;
quit;

Is This Answer Correct ?    0 Yes 0 No

There is a field containing a date. It needs to be displayed in the format "ddmonyy" i..

Answer / vijs

data new ;
input date ddmmyy10. ;
cards;
01/05/1955
01/09/1970
01/12/1975
19/10/1979
25/10/1982
10/10/1988
27/12/1991
;
run;

proc format ;

value dat low-'01jan1975'd=ddmmyy10.
'01jan1975'd-'01JAN1985'd="Disco Years"
'01JAN1985'd-high=date9.;
run;

proc print;
run;

proc print;
format date dat. ;
run;

Is This Answer Correct ?    3 Yes 5 No

There is a field containing a date. It needs to be displayed in the format "ddmonyy" i..

Answer / kavitha

DATA D1;
INPUT SLNO DATE DATE9. ;
DATALINES;
1 12DEC08
2 22NOV08
3 01JAN08
4 12FEB07
5 13MAR07
6 24APR06
7 17MAY06
8 20JUN05
9 29JUL05
10 30APR09
;
RUN;

proc format ;
value KAVI low-'31DEC2006'd='***ddmonyy***'
'01JAN2007'd-'31DEC2007'd='***dd mon ccyy***'
'01JAN2008'd-high=' **Disco Years **';
RUN;

proc print data=D2 noobs label;
format DATE KAVI.;
RUN;

Is This Answer Correct ?    2 Yes 5 No

Post New Answer

More SAS Interview Questions

what do the pad and dim functions do? : Sas programming

0 Answers  


I Here clinical SAS training by Ramesh Azmeera is good. Is it confirm ?

2 Answers  


What type of tables you are using in YOUR reporting..???

2 Answers   GSK GlaxoSmithKline,


What will calendar procedure do?

0 Answers  


what does .. meant in sas macros

3 Answers   D&B,


what is the Population you used in your project, is it ITT or PP?

0 Answers   Accenture, Quintiles,


what is sas olap server? : Sas-di

0 Answers  


Hi all, If Anybody has Advance SAS Certification dumps??? Please share with me. Email: pramod.kalugade03@gmail.com

0 Answers  


What are the ways to do a “table lookup” in sas?

0 Answers  


what other SAS features do you use for error trapping and data validation?

3 Answers   Quintiles,


if reading an external file to produce an external file, what is the shortcut to write that record without coding every single variable on the record

4 Answers   HSBC,


how to read the variables in sas? : Sas-administrator

0 Answers  


Categories