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;
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.