***************************************; * f=prog_mbquest2.sas *; * *; * SAS code to answer the research- *; * oriented questions, using the *; * simulated MB Health data in a *; * program that creates the necessary *; * code in one data step. *; * This assumes the temporary SAS *; * set "test" has been created. *; * *; * NOTE: the "formchar" option in the *; * PROC FREQ statements were required *; * here to enable Web display of *; * tables - it is not normally needed. *; ***************************************; %include 'c:\winnt\profiles\Ruth\personal\My SAS files\sasmanual\formats\fmts95.sas'; data final; set test; ****---Question 1-----****; lensop = ('13 '<=op01<='1399'); /* Flag eye operations */ *Another way of flagging the eye operations: *; lensop2=substr(op01,1,2)='13'; *(Question 2 does not need new variable code)*; ****---Question 3----****; if '820 '<=diag01<='82099' then hipfx=1; else if '820 '<=diag02<='82099' then hipfx=1; else hipfx=0; *(Note that substring could be used instead. Also note that a DO loop, with an ARRAY, can be used for performing repetitive tasks such as the above and should be used when many fields need to be processed.) *(Question 4 does not need new variable code)*; ****---Question 5-----****; deathall= (.