BookmarkSubscribeRSS Feed
NoorulIyn
Calcite | Level 5

I came across this program on SAS book.Do we need the informat statement here?What is the difference between the formatted input date and the informat statement

data aes;

label USUBJID  = 'Unique Subject Identifier'

           AESTDTC = 'Start Date/Time of Adverse Event'

           AEENDTC = 'End Date/Time of Adverse Event'

           AETERM = 'Reported Term for the Adverse Event';

informat AESTDTC  date9. AEENDTC  date9.;

input @1 USUBJID $3.

@5 AESTDTC date9.

@15 AEENDTC date9.

@25 AETERM $15.;

datalines;

101 01JAN2004 02JAN2004 Headache

101 15JAN2004 03FEB2004 Back Pain

102 03NOV2003 10DEC2003 Rash

102 03JAN2004 10JAN2004 Abdominal Pain

102 04APR2004 04APR2004 Constipation

;

run;

1 REPLY 1
ballardw
Super User

Using the format as part of an input statement occasionally has issues with column alignment if you aren't providing fixed columns or delimited data to read from. Standard dates aren't much of an issue though custom formats and string values can be entertaining on occasion. Also if you have an INFORMAT supplied on the INPUT it overrides the INFORMAT statement. The column order of the variables can be set with an informat or length statement(s) prior to input if you would like them to appear in other than supplied data order as well.

See the result here:

data aes;

label USUBJID  = 'Unique Subject Identifier'

           AESTDTC = 'Start Date/Time of Adverse Event'

           AEENDTC = 'End Date/Time of Adverse Event'

           AETERM = 'Reported Term for the Adverse Event';

informat AESTDTC  date9. AEENDTC  date9.;

input @1 USUBJID $3.

AETERM $15.

AESTDTC date9.

AEENDTC date9.

;

datalines;

101  Headache 01JAN2004 02JAN2004

101  Back Pain 15JAN2004 03FEB2004

102  Rash 03NOV2003 10DEC2003

102  Abdominal Pain 03JAN2004 10JAN2004

102  Constipation 04APR2004 04APR2004

;

run;

Compared with:

data aes2;

label USUBJID  = 'Unique Subject Identifier'

           AESTDTC = 'Start Date/Time of Adverse Event'

           AEENDTC = 'End Date/Time of Adverse Event'

           AETERM = 'Reported Term for the Adverse Event';

informat AESTDTC  date9. AEENDTC  date9.  AETERM $15.;

input @1 USUBJID $3.

AETERM

AESTDTC

AEENDTC

;

datalines;

101  Headache 01JAN2004 02JAN2004

101  Back Pain 15JAN2004 03FEB2004

102  Rash 03NOV2003 10DEC2003

102  Abdominal Pain 03JAN2004 10JAN2004

102  Constipation 04APR2004 04APR2004

;

run;

It also affects how spaces in data may be interpretted

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 713 views
  • 0 likes
  • 2 in conversation