In this example, you have a string which represents 10 single-digit scores for a person.This "packing" of data is done to either save space or to reduce the number of variables per person.In many database packages (especially those for PC's), there is a limit to the number of variables that may be contained in a single database.By using a single variable to represent multiple scores, you can "trick"the program into functionally holding more variables than the actual maximum.
After you transfer this data set into a SAS System file, you have a 10-byte character variable from which you want to extract the 10 scores.The SUBSTR function, placed in a loop with the index "pointing"to each of the scores in turn, accomplishes your goal.Here it is: (Data set OLD contains a character variable STRING which holds the 10 scores.)
Here you place the SUBSTR function inside a DO loop which gets executed 10 times, once for each value of the counter J (1 to 10). Each time the loop is executed, another byte is extracted from STRING.Each of the X variables is equal to the value of one of the bytes in the 10-byte variable STRING. Since you want the variables X1 to X10 to be numeric, you create the array that holds them as a numeric array.
Since the original variable STRING is character, you use the INPUT function to make the characterto- numeric conversion (see Example 5).If you omit the INPUT function, the SAS System performs an automatic character-to-numeric conversion.We prefer programming the conversion ourselves.
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.