SAS dates

Reply
Occasional Contributor
Posts: 5

SAS dates

Hi ,

I created a new dataset  and couldnt able to read date values.

I used below code.

Please explain my mistake in formatting.

Thanks

data new;

infile datalines dsd;

input USUBJID 1-2 EXTRT$4-10 EXSTDTC$12-20 EXENDTC$22-30;

informat EXSTDTC EXENDTC anydtdte.;

format EXSTDTC EXENDTC date9.;

datalines

;

01 calcim 12may2013 30dec2013

01 potass 30may2013 25dec2013

02 calcim 20jun2012 25jan2013

02 potass 23apr2011 30dec2012

;

run;

proc print ;

run;

Respected Advisor
Posts: 4,925

Re: SAS dates

Option DSD implies that your data fields are separated by commas, you don't need it. Also, it is not possible to read non-standard data values such as dates with column input. You could use modified list input instead :

data new;

input USUBJID 1-2 EXTRT $ 4-9 EXSTDTC :anydtdte. EXENDTC :anydtdte.;

format EXSTDTC EXENDTC date9. USUBJID z2. ;

datalines

;

01 calcim 12may2013 30dec2013

01 potass 30may2013 25dec2013

02 calcim 20jun2012 25jan2013

02 potass 23apr2011 30dec2012

;

run;

proc print ;

run;

PG

PG
Occasional Contributor
Posts: 5

Re: SAS dates

Thank you so much!

Ask a Question
Discussion stats
  • 2 replies
  • 171 views
  • 1 like
  • 2 in conversation