Hi Team,
I have a question from the following code below.
Is the IF condition below being applied to all the 3 datasets being created in the data step???:
The variables in the IF condition are only present in the "SickleDxICD9_code" dataset. I was wondering how all the 3 datasets end up having 322 variables in the end????
if put(ICD9_Code,$SICKLE.)='1' or current_icd9_list='648.20, 282.60';
data SickleDxICD9_code(keep=dx_id ICD9_Code current_icd9_list)
SickDxid_fmt(keep=start label fmtname)
Dxid2Code_fmt(keep=start label2 fmtname2 rename=(label2=label fmtname2=fmtname));
set HAVE(keep=dx_id dx_name diagnosis_code current_icd9_list REF_BILL_CODE_SET_C RECORD_TYPE_C);
where current_icd9_list^='';
length icd9_code $12;
legth=index(current_icd9_list,',')-1;
if legth=-1 then legth=length(current_icd9_list);
ICD9_Code=substr(current_icd9_list,1,legth);
start=dx_id;
label='true';
fmtname='sickdxid';
label2=current_icd9_list;
fmtname2='dxid2code';
if put(ICD9_Code,$SICKLE.)='1' or current_icd9_list='648.20, 282.60';
run;
NOTE: There were 821061 observations read from the data set HAVE.
where current_ICD9_list not = ' ';
NOTE:The data set WORK.SICKLEDXICD9_CODE has 322 observations and 3 variables.
NOTE:The data set work.SickDxid_fmt has 322 observations and 3 variables.
NOTE:The data set work.Dxid2Code_fmt has 322 observations and 3 variables.
As you have already noticed, the IF statement applies to all three output data sets.
One of the key concepts here is that the DATA step is not processing the output data sets. It's processing the input, and then putting the results into the output data sets. So all the variables are available to the DATA step to inspect and calculate. Any observation that makes it past the IF automatically gets output to all three data sets.
Good luck.
As you have already noticed, the IF statement applies to all three output data sets.
One of the key concepts here is that the DATA step is not processing the output data sets. It's processing the input, and then putting the results into the output data sets. So all the variables are available to the DATA step to inspect and calculate. Any observation that makes it past the IF automatically gets output to all three data sets.
Good luck.
Thanks Astounding.
I understood the logic behind it.
Thanks
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.