- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Would you mind letting me know the difference of those two codes? I really don't know functionally what the difference is / what makes the difference of the 2 observations.
1)
data cleandata36;
set cert.input36;
if upcase(Group) in ('A', 'B') then do;
end;
run;
proc contents data=cleandata36;
run;
2)
data cleandata36;
set cert.input36;
if upcase(Group) in ('A', 'B');
run;
proc contents data=cleandata36;
run;
"Then do" is one difference. So, the only one difference of two codes is 'observation'
1)
Observations
5000 |
2)
Observations
4992 |
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The first IF, will execute conditional logic between the DO/END statement but you have nothing so the first IF doesn't do anything. If you added a DELETE in between the DO;/END; it will then be the same.
if upcase(Group) in ('A', 'B') then do;
DELETE;
end;
In general, you use IF/THEN/DO when you want to do more than one thing in the step. If you want to filter or only do one thing then you can stick with IF/THEN.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
stands for
if upcase(Group) in ('A', 'B') then output;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The IF Statement: Subsetting causes the data step (if the condition does not resolve to true) to immediately return to the top, skipping any remaining statements and starting the next iteration. This also means that the implicit OUTPUT at the end of the data step (if no explicit OUTPUT was coded) is not performed.
The "normal" IF does not do this, and therefore all observations in your example are kept.