Instead of using starting and ending column numbers to describe the location of the data,you can use the starting column number,the length of the data value (number of columns it occupies),and a SAS informat.A typical data description containing information about the previouscollection of data might look like the following:
The following code uses pointers and informats to read instream data that occur in the pattern described above.
The @ characters (at signs) are called column pointers;they indicate the starting column for an action.When they appear before a variable name in an INPUT statement,they tell the SAS System to go to a certain column. Following the name of the variable, you can use an informat to tell the program how to read the data.
There are many types of SAS informats,but we only use a few common ones here.Numeric variables use an informat of the form w.d,where w is the width of the field (number of columns)containing the data,and d is the number of places to the right of the decimal point in the value. When d is omitted, it is assumed to be 0.If the data values actually contain decimal points,the d part of the specification is ignored.
A minus sign (-) may be included in a negative value,but it mustimmediately precede the value with no intervening space.The width,w,must be large enough to include any decimal points or minus signs found in the data. Character informats are of the form $w.,where w is the width of the field (number of columns)containing the data.
There are a large number of dale informats in the SAS System.The one used here, MMDDYY6.,instructs the software to read a data value from six columns, the first two being the month,the next two the day of the month,and the last two being the year. If the values contain special characters (typically slashes or dashes) separating the three parts of the dale, you can use MMDDYY8. instead.
All SAS informats contain a period (.), either as the last character in the formal or immediately preceding the number of decimal places contained in a data value.Omitting this period, like omitting the "sacred semicolon, "can,under the right circumstances,cause countless hours of head-scratching while trying to discover why the obtained results are so wrong!It is quite possible to omit a period or semicolon and still have "syntactically correct"code.Of course the results may be pure garbage.Two words to the wise are all that we can offer.BE CAREFUL!! Output from the previous code in Example 6 is as follows
Output from Example - Reading Column Data That Require Informats
Notice that the values for DOB are printed in MM/DD/YY formal.This is accomplished withthe line of code,FORMAT DOB MMDDYY8. (See the writeup accompanying Example 3.1 for an explanation).
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.