The column Input in SAS is one of the methods to read raw data files with spaces or delimiters between all the values or periods for missing numeric data.
Column input lets you read different values from each record in the same column.
To use column input, list the names of the variables in the INPUT statement. Then, right after each variable name, write the column position in each data line that goes with that variable. (Of course, you’ll need to put a dollar sign ($) before each character variable.)
Column input can be used when your raw data is in fixed columns and has a standard format for characters or numbers. Column input reads data values until it reaches the last column for the specified field.
Column input in SAS has the following advantages over list “input”:
Syntax
INPUT variable <$> start-column<–end-column> <.decimals> <@ | @@>;
The important points to note about column input “are”:
data Students;input name $ 1-18 age 25-27 weight 30-32;datalines;Joseph 11 32Mitchel 13 29Sue Ellen 14 27;run;

The .decimals argument is used to read values from input lines and insert a decimal place into data that does not have an explicitly defined decimal.
If the data contains an explicit decimal, it is not changed. Instead, the data is padded to match the greatest number of significant digits occurring in any output data after conversion.
data product;input cost 1-5 .2;datalines;26.7721.004003.212.569;run;

This is an example that reads a file that contains two types of input data records and creates a SAS data set from these records.
One type of data record contains information about a particular college course. The second type of record contains information about the students enrolled in the course.
You will need two INPUT statements to read the two records and to assign the values to different variables that use different formats.
Records that contain class information have a Course in column 1, and records that contain student information have a Student in column 1, as shown “below”:
----+----1----+----2----+Course HISTORY WatsonStudent Williams 0459Student Flores 5423Course MATHS SenStudent Lee 7085
data students(drop=type);retain Course Professor;input type $7. @;if type='Course'then input course $ professor $;else if type='Student' then do;input Student $10. Id;output students;end;datalines;Course HISTORY WatsonStudent Williams 0459 Student Flores 5423Course MATHS SenStudent Lee 7085;run;

This example shows how to create multiple observations for each input data record. Each record contains several NAME and AGE values.
The DATA step reads a NAME value and an AGE value, writes an observation, and then reads another set of NAME and AGE values to output until all the recorded input values are processed.
data test;input name $ age @@;datalines;Joseph 13Mitchel 12Sue 15Stephen 10Marc 22Lily 17;run;

If each variable’s values are always arranged in the same place in the data line, then you use column input in SAS as long as all the values are character or standard numeric.
Standard numeric data contains only numerals, decimal points, plus and minus signs, and E representing scientific notation.
If the numbers have embedded commas or dates are not standard numeric data.
If you liked this article, you might also want to read Importing Data using PROC IMPORTas well.
Do you have any tips to add? Let us know in the comments.
Please subscribe to our mailing list for weekly updates. You can also find us on Instagram and Facebook.
