





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
Material Type: Notes; Professor: Davenport; Class: INTRO TO STATISTICAL COMPUTING; Subject: Statistics; University: Virginia Commonwealth University; Term: Unknown 1989;
Typology: Study notes
1 / 9
This page cannot be seen from the preview
Don't miss anything!






Well, that last example with the errors didn’t work. So, we are going to need ways to better control our input options. List input is nice, since you don't have to worry about the specific columns in which the data fields lie. Question: Can we combine the features of LIST input and FORMATTED? COLON (:) FORMAT MODIFIER Yes, using the colon (:) format modifier. You can use list input rather than column or formatted input to read data, even when they contain values that require an informat modifier to be read correctly. The colon (:) format modifier allows you to use list input for reading character data containing more than eight (?) characters or data requiring informats (numeric data that contain invalid characters). (See Program SAS_Lec03_input_01.sas)
data jansales; input item : $10. amount : comma5.; lines; trucks^1, jeeps^1, landrovers^2, lincoln navigators^1, ; proc print data=jansales; title ‘January Sales in Thousands’; run; quit; “item” has length 10 and “amount” requires a format to strip the comma. Place a colon between the variable name and the informat. As in simple list input, at least one blank must separate each value from the next, and character values cannot contain embedded blanks.
COLUMN POINTER CONTROLS : (especially useful with mixed input and formatted style input) @ @@ @n +n / #n Let us first consider the “ @n” and the “+n” pointer control. input item $10. @17 amount comma5.; cards; trucks 1, jeeps 1, landrovers 2, ; column 17 OR input item $10. +6 amount comma5.; cards; trucks 1, jeeps 1, landrovers 2, ; +n in the input statement moves the pointer n columns to the right.
The data must be aligned in columns, when you have... -- column input - you specify the columns -- formatted input - you specify length with informats, and move the pointer with pointer controls. Points to Remember -- formatted input reads until it has read the number of columns indicated by the informat. It overrides the default of stopping when a blank is read. -- you can position the pointer with pointer controls @ @@ @n +n / #n -- you can read data stored in nonstandard forms -- with informats you retain all of the flexibility & features of column input. Recall that when reading with list input, the pointer is left in the column immediately after the last read column.
the NEXT column after the first blank is read. Let’s now consider the other types of pointer control. ***** Using the Pointer Control “ # “ To Read*** *** multiple records into the buffers ***** You can read multiple records to create a single observation by pointing to a specific record in a set of input records with the #n line-pointer control. Using the #n control allows you to read the variables in any order, no matter how the variables are listed in the records or no matter which record contains the variable. It is also useful if you want to skip lines of raw data. data one; input # 2 team $ 1 - 6 # 1 name $ 6 - 23 idno 1 - 4
cards; 1023 David Shaw red 189 195 1049 Amelia Serrano yellow 145 124 1051 Tim Jones green 190 178 ; proc print ; var idno name team strtwght endwght; run ; quit; (See Program SAS_Lec03_input_04.sas) ***** Reading a Record twice (the trailing @ ) *****
Place a trailing @ before the semicolon at the end of the INPUT statement instructs SAS to hold the current record in the input buffer so it is available for a subsequent action (additional INPUT statements, logic statements, assignment statements, etc.). The current line in the buffer will be released by the end of the DATA STEP. Recall that SAS automatically releases the current record and reads the next record into the buffer after the end of a DATA STEP -- actually upon the encounter of in INPUT statement at the top of the DATA STEP. data redteam; input team @21 team $6.@; if team='red'; input idno 1-4 name $ 6-19 @28 strtwgth endwght; cards; 1023 David Shaw red 189 165 1049 Amelia Serrano yellow 145 124 1051 Tim Jones green 190 178 ; (See Program SAS_Lec03_input_05.sas) Let us look at some examples of how not to use the single trailing @. (See Program SAS_Lec03_input_06.sas) (See Program SAS_Lec03_input_07.sas)