



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Various input types and attributes in sas, including list, column input, and formatted input. It covers restrictions, pointer movement, and mixing different input types. Examples are provided to illustrate each concept.
Typology: Study notes
1 / 5
This page cannot be seen from the preview
Don't miss anything!




Defining Variables - done in the Input Statement sets attributes name type length informat (if any) format (if any) label (if any) the default is numeric and length is 8 bytes (the length of numerical variables is not affected by informats or column specifications, but can be increased to something similar to double precision -- we will discuss this later Following the variable name with a $ changes the type of the variable to a character variable of length of 8 bytes for list input. You can push this to 200 characters by using either input name $ 1-200; or input name $200.; We will talk about the "format" and "label" attributes at the end of the lecture.
Line # 1 of input records: pointer input buffer column # the input statement brings data to the input buffer & gives you control over how to move the data from the buffer to the data vector via "the data pointer" Things that affect your choice of input style (see Chapter 2 of your text). -- How the data is entered on the records (cards, etc.)? -- How you would like to enter the data? -- Do character variables have imbedded blanks? -- Do numeric variables contain non-numeric character? ( $ , % ) -- Do the data contain time or date values that require special instructions? -- Is there more than one observation per input record? -- Is the data for a single observation spread over several input records?
Input type: COLUMN INPUT Data values occupy the same fields within each record. You specify these column locations in the INPUT statement. -- data must be standard character or numeric form -- when using column input, your aren't required to indicate missing values with a placeholder such as a period -- uses the columns specified to determine length of character input variables -- unlike LIST, it reads data until it reached the end of the last specified column, not until it reaches a blank -- can skip columns altogether -- read columns in any order -- can read only a part of a value or reread the value -- character variables can be up to 200 characters in length (See Program SAS_Lec#2_input_02.sas) Input type: FORMATTED INPUT Data can be stored in special formats such as binary, packed decimal, special formats (time & dates), or imbedded commas and monetary symbols. So we need ways to input this data. You must use SAS’s pre-programmed formats. (See Program SAS_Lec#2_input_03.sas)
You can mix formatted input with column input. An example of column input and formatted input: input item $ 1-18 amount comma5.; format amount comma5.; lines; an “informat” trucks 1, ; column 19 (See Program SAS_Lec#2_input_04.sas) You can mix formatted input with list input as well, but need to be careful, or you will experience errors. input item $ amount comma5.; format amount comma5.; label item = ‘Type of Vehicle’ an “informat” amount = ‘Number of Vehicles Sold’; lines; trucks 1, ; (See Program SAS_Lec#2_input_05.sas) Other variables attributes: This example also shows the use of the other two attributes we defined earlier, namely “formats” and “labels”. Notice that with this program, we experience what are called truncation errors. We need ways to mix these input modes so that this doesn’t happen.