Hi,
Unintentionally I created code that, within 1 data step, had a set of 'input' statements
(e.g
pat_age = input(pat_age, dot_or_ninetynine.)
)
followed by infiling the data. As I didn't receive 'uninitilized errors' it's made me curious how SAS handles statements about variables that don't yet exist - in that the code for reading in raw data follows statements referring to the data. Or the variable is created 'later' in the statements and isn't read in with the raw data.
Any references to explain the order of operations for statements?
Hope that's clearer than mud,
Anjali
I would have to think that you either had another infile statement before that or that you received an error in your log.
The behavior, which is executable, is defined on the lower part of the page at:
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146932.htm
Yes, I stand corrected. The INFILE precedes all else - but I'm still curious if/when the formatting will be applied. Example:
**********************************************************************
322 data stout.&state._BirthData01 ; /* data read in to become formatted data */
323 length bc 8.;
324 infile stbirth LRECL=&birthreclength linesize=&birthlinesize
325 N=&birthLinesPerObs missover;
326 %create_code_statements(birthfmt, pramsvars) /*informats for formatting birth file */
MPRINT(CREATE_CODE_STATEMENTS): mat_age = input(mat_age, dot_or_ninetynine.);
MPRINT(CREATE_CODE_STATEMENTS): pnc_mth = input(pnc_mth, month_pncf.);
MPRINT(CREATE_CODE_STATEMENTS): momcig = input(momcig, momlbsf.);
327 %create_input_string_fmt(statevars, birth)
MPRINT(CREATE_INPUT_STRING_FMT): input #1 @0001 yy4_dob ? yy4f. @;
MPRINT(CREATE_INPUT_STRING_FMT): if _error_ or yy4_dob=. then yy4_dob=.U ;
MPRINT(CREATE_INPUT_STRING_FMT): _error_=0;
MPRINT(CREATE_INPUT_STRING_FMT): input #1 @0005 b_state ? $char2. @;
MPRINT(CREATE_INPUT_STRING_FMT): input #1 @0007 certnum ? $char6. @;
MPRINT(CREATE_INPUT_STRING_FMT): input #1 @0013 void ? $char1. @;
MPRINT(CREATE_INPUT_STRING_FMT): input #1 @0026 tb ? 4. @;
...
328 %create_code_statements( birthcalc, pramsvars )
(infdob and momdob created at some point here)
MPRINT(CREATE_CODE_STATEMENTS): mat_age = year(infdob) - year(momdob);
***********************************************************************************
In that temporal order - will the initial lines:
MPRINT(CREATE_CODE_STATEMENTS): mat_age = input(mat_age, dot_or_ninetynine.);
MPRINT(CREATE_CODE_STATEMENTS): pnc_mth = input(pnc_mth, month_pncf.);
MPRINT(CREATE_CODE_STATEMENTS): momcig = input(momcig, momlbsf.);
have no effect as they precede the creation of the variables to be formatted?
Thank you.
I think you might find the following paper quite helpful in understanding what is going on under the hood:
Thank you. I'm sure the explanation is in there - might need a 'dummies' version to truly get it.
Thanks!
Anjali
I wouldn't call the following "PDV for Dummies", but you might find it an easier read .. although I'd recommend reading both and more.
http://support.sas.com/resources/papers/proceedings09/136-2009.pdf
I am not seeing the link/attachment for the 2nd recommended article. Thank you.
Look again .. I just added it
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 how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.