Help using Base SAS procedures

informat statement

Reply
Contributor
Posts: 27

informat statement

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;

Super User
Posts: 11,343

Re: informat statement

Posted in reply to NoorulIyn

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

Ask a Question
Discussion stats
  • 1 reply
  • 182 views
  • 0 likes
  • 2 in conversation