In the SAS Data step what is the difference between the
subsetting done by Where and subsetting done by If?
Answer Posted / gangadhar
Make sure you apply the following rules when determining
which approach to take when subsetting your data set using
the DATA step. If your subset condition does not meet the
requirements below, then the WHERE and IF statements should
produce identical results. For cases such as this, use the
WHERE statement since it is more efficient. Note that
having both WHERE and IF statements within the same DATA
step has a cumulative effect.
• Can use WHERE statement when only specifying data
set variables
• Use IF statement when specifying automatic
variables or new variables created within DATA step
• Use IF statement when specifying FIRST.BY or LAST.
BY variables
• Use IF statement when specifying data set options
such as OBS = , POINT = or FIRSTOBS =
• In general, use IF statement when merging data sets
to apply subset condition after merging data set
• Use WHERE statement when specifying indexes
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
Explain the main difference between the sas procedures and functions? : Sas-administrator
What are the five ways to do a table lookup in sas? : sas-grid-administration
How will you use the WHO Drug Dictionary for Reporting Clinical Trials?
What are types of transport files?
How do you control the number of observations and/or variables read or written? Approximately what date is represented by the SAS date value of 730?
How do you use the do loop if you don’t know how many times you should execute the do loop?
what is star schema? : Sas-di
What do you know about sas data set?
do you prefer proc report or proc tabulate? Why? : Sas programming
What would you change about your job?
what is sas data set?
In SAS explain which statement does not perform automatic conversions in comparisons?
what is transformation in sas data integration? : Sas-di
Mention common programming errors committed in sas ?
data data1; input dt account; format dt date9.; cards; 1745 1230 1756 1120 1788 1130 1767 1240 ; data data2; input startdt enddt total; format startdt date9. enddt date9.; cards; 1657 1834 12300 1557 1758 16800 1789 1789 12300 1788 1345 12383 1899 1899 13250 ; proc sql; create table data3 as select * from data1 as x left join data2 as y on x.dt>=y.startdt and x.dt<=y.enddt; quit; Here, we are getting cartision product. But,I want left join report consisting of this program. It should not get duplicate values. you can modify the program also.