@Beanpot wrote:
Hi, I'm working on a dataset that was given to me in .txt format. The codebook gives me the names, positions and lengths of the variables. But the variables themselves are not labeled in the text file. When I import the datafile the contents looks like this:
How do I tell SAS where the variables are? In other words the name of variables 1, 2, 3, etc., their locations (e.g. position 20), and lengths (e.g. 1 character or 3 characters)?
Is the codebook too sensitive to share some of the details? If not share some of the book and we can probably get you started.
It is not unlikely that you may have to modify the names of variables depending on what you were given. SAS variable names are limited to 32 characters and only letters, digits and the _ character. So if the names don't fit those rules then modify the names to fit SAS rules and use a LABEL for the variables to get a nicer description in the data.
If the codebook is in a nice enough format, such as word processor tables or spreadsheets I have even used spreadsheets to generate the informat and input statements, variable names and labels reduce typing. Considering that some of the sets I have had to deal with have upwards of 500 variables that can be quite a time saver.
... View more