02-11-2017 03:14 PM
Hi All - I'm running the following code, SAS found the specified file but is unable to read the datalines, in particular Rent. When I select the OUTPUTDATA tab, I can see the Gender but none of the other data columns Rent, Utilities, Roommates. I'm new to SAS, I might be doing something wrong.
proc means data=housing mean stddev clm;
02-11-2017 03:36 PM
data housing; infile '/folders/myfolders/housing.txt'; input Gender $ Rent Utilities Roommates; run;
02-11-2017 03:39 PM
is used to include data in the data step for reading with input (so you don't use an external file).
02-12-2017 02:35 PM
02-12-2017 02:53 PM
You don't want DATALINES statement in your program, since your data is actually in a separate file that you have already pointed to with the INFILE statement. Plus your INPUT statement is only listing one variable name and your data file has four columns of data.
You probably want to use this program instead.
data housing; infile '/folders/myfolders/housing.txt' truncover; input Gender $ Rent Utilities Roommates ; run;
The first line tells SAS that you want to start a data step to create the dataset HOUSING. The second line tells SAS where to find the raw data to read. The TRUNCOVER option will prevent SAS from reading more than one at a time when the line does not have enough values.
The third line tells SAS to read four values from each line. The first one is read a text and the last three are read as numbers. Since you didn't define the variables in advance SAS will reserve 8 bytes for each of them. The character variable Gender will only be able to hold 8 characters. The three numeric variables will be stored using the full 64 bit floating point representation that SAS uses for all numbers.