When you have raw data that you want to turn into a SAS data set,and you want to change the format in which some of the data values are stored,you can do it in one of two ways.You can either read the data as they occur in their raw form,insert them into the SAS data set you are building,and then change the values via conditional assignment statements, or you can "prescreen" the raw data on the way into the data set and make changes to the values before they are stored as SAS variable values.
The latter method is usually used for efficiency purposes. In this example, you use both methods.First, you read raw data into a SAS data set as they appear and change the stored values.Then you use an alternative method to change the data as they are being read in.
Suppose you have data coded as 'M' for male and 'F' for female, and you want to set all values other than 'M' or 'F' to a missing value (blank). A straightforward way to do this is to simply supply some logic statements in the DATA step as follows:
ExampleDATA SCREEN4 ;
The IF statement with the IN operator as shown is equivalent to:IF GENDER NOT='M' AND GENDER NOT='F' THEN GENDER=' ';
The result of this code is that all values of GENDER other than 'M' or 'F',including missing values (' '), are first read into data set SCREEN4,and then changed into a missing value (blank).Each value already coded as blank is "changed" into itself.
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.