- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What does it mean when an if statement is only followed by the name of a library?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
As a new user, it's understandable that you wouldn't understand:
IF FIRST.SHORT_ACCOUNT_NUMBER;
It's actually more complicated than it looks, so I can give you the overview only.
IF deletes observations, and continues to process other observations. The ones that satisfy the IF condition continue to be processed, and the others get deleted.
FIRST.SHORT_ACCOUNT_NUMBER is created in a DATA step using a BY statement. What it does, and how it works, will take some study on your part. (You have already been pointed to some reference material.)
The net result in this program handles cases where there are multiple observations for the same SHORT_ACCOUNT_NUMBER:
- Just keep the first observation for each SHORT_ACCOUNT_NUMBER
- Delete any remaining observations for the same SHORT_ACCOUNT_NUMBER
Hope this at least points you in the right direction.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You mean "name of a variable"?
If that's the case, you are referring to a "subsetting if". It means that any observation that does meet the criteria, is not processed further on in the data step. So any explicit or implicit output will not be performed.
If you just name a variable, for a numerical value of 0 means false (subset will occur), any other value is evaluated as true (processing will proceed with the following steps).
Do you have an example?
Try to execute it, evaluate the results. Potentially change input data/IF statement and see the differences.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
for example:
DATA CR_OPEN_IO_PART_TEMP_1; SET CR_OPEN_IO_PART_TEMP; BY SHORT_ACCOUNT_NUMBER; IF FIRST.SHORT_ACCOUNT_NUMBER; RUN; |
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The by statement:
BY SHORT_ACCOUNT_NUMBER;
Creates a binary value, 1 for true, 0 for false, which is set based on whether a value is the first occurrence of a value in that variable. A bit like:
SHORT_ACCOUNT_NUMBER ISFIRST
A 1
A 0
...
The if:
IF FIRST.SHORT_ACCOUNT_NUMBER;
Is the same as saying: if isfirst=1 then output;
Please dont code all in uppercase, it makes code painful to read.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
As a new user, it's understandable that you wouldn't understand:
IF FIRST.SHORT_ACCOUNT_NUMBER;
It's actually more complicated than it looks, so I can give you the overview only.
IF deletes observations, and continues to process other observations. The ones that satisfy the IF condition continue to be processed, and the others get deleted.
FIRST.SHORT_ACCOUNT_NUMBER is created in a DATA step using a BY statement. What it does, and how it works, will take some study on your part. (You have already been pointed to some reference material.)
The net result in this program handles cases where there are multiple observations for the same SHORT_ACCOUNT_NUMBER:
- Just keep the first observation for each SHORT_ACCOUNT_NUMBER
- Delete any remaining observations for the same SHORT_ACCOUNT_NUMBER
Hope this at least points you in the right direction.