To prevent the previous situation from happening, you cannot merely rely on the presence of a value for DOB.Instead, you need to set the variable OLD_DOB equal to DOB each time you read data from what you know to be a new subject.
How do you tell when you have reached a new subject? One approach is to compare the current value of SUBJ to the previous value by using the LAG function.
This function is another powerful and easily misunderstood (and misused) feature of the SAS System.The LAG function works by returning the value of its argument the last time it (the LAG function) was executed. If you execute the LAG function for every observation, its value is the value of the variable from the previous observation.The statementIF SUBJ NE LAG(SUBJ) THEN OLD_DOB=DOB; 0
sets OLD_DOB equal to DOB each time a new subject is encountered (even if DOB is missing). Here is the code that works:
The correct results are shown in Output 6.
Output from Example - Checking for a New Subject Number Using a LAG Function
SAS Programming Related Tutorials
|SASS (Syntactically Awesome Style sheets) Tutorial||R Programming language Tutorial|
SAS Programming Related Interview Questions
|Logistics Interview Questions||SAS Programming,SQL server Interview Questions|
|Clinical SAS Interview Questions||SASS (Syntactically Awesome Style sheets) Interview Questions|
|SQL Server Analysis Services (SSAS) Interview Questions||R Programming language Interview Questions|
|SAS DI Interview Questions||Advanced SAS Interview Questions|
|Base Sas Interview Questions||SAS Macro Interview Questions|
|Clinical Data Management Interview Questions|
Sas Programming Tutorial
Input And Infile
Set, Merge, And Update
Table Lookup Tools
Proc Means And Proc Uimivariate
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.