Previous PageNext Page

Selecting Records with an IF statement: When do you use it?

In the creation of a data set from raw data, say, we may wish to select only certain records. We can do this with an IF statement. But where do you put the IF statement? Here are two pieces of code. Which is more efficient?

Code 1:

Data Billing;
	input ID $7. Eligible $3. (ICD9_1-ICD9_3) ($6.)
		Gender $Upcase1. DOB mmddyy8. DOV mmddyy8.;
	if Upcase(Eligible)="YES";
	format DOB DOV date9.;
	drop Eligible;
	datalines;
abcdefgyes239.32V70.        m0425196008102000
lmnopqrno 244.0 V70.  120.20F1125195008112000
run;

Proc Print data=Billing;
run;

Code 2:

Data Billing;
	input @8 Eligible $3. @;
	if Upcase(Eligible)="YES";
	input ID $7. @11 (ICD9_1-ICD9_3) ($6.)
		Gender $Upcase1. DOB mmddyy8. DOV mmddyy8.;
	format DOB DOV date9.;
	drop Eligible;
	datalines;
abcdefgyes239.32V70.        m0425196008102000
lmnopqrno 244.0 V70.  120.20F1125195008112000
run;

Proc Print data=Billing;
run;

Previous PageTable Of ContentsNext Page