Help using Base SAS procedures

DATA STEP LOGIC

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,041
Accepted Solution

DATA STEP LOGIC

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.




Accepted Solutions
Solution
‎02-25-2015 01:15 PM
Super User
Posts: 5,516

Re: DATA STEP LOGIC

Posted in reply to robertrao

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.

View solution in original post


All Replies
Solution
‎02-25-2015 01:15 PM
Super User
Posts: 5,516

Re: DATA STEP LOGIC

Posted in reply to robertrao

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.

Super Contributor
Posts: 1,041

Re: DATA STEP LOGIC

Posted in reply to Astounding

Thanks Astounding.

I understood the logic behind it.

Thanks

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 193 views
  • 0 likes
  • 2 in conversation