Hello everyone,
I have a data set with a variable "Age" looking like this:
Age
10-14
10-14
15-19
.
.
.
It is a tab-delimited data, so I use the code as below:
infile "&dirdata.SAS_Test/file_name.txt" delimiter="09"x DSD truncover firstobs=2;
But the printout would be a typo between 10 and 14 for the variable "Age",
and influence my following analysis as SAS would complain for invalid symbol.
Thank you very much for all the suggestions!
Thanks!
You should be able to read such data with:
data myData;
infile "&dirdata.SAS_Test/file_name.txt" delimiter="09"x DSD truncover firstobs=2;
input age$ /* other fields */;
run;
the $ tells SAS that age is a character variable.
Hi:
Your INPUT statement is more important in this case than you INFILE statement. Are you trying to read age as a numeric variable or as a character variable? The value 10-14 is NOT valid as a numeric value. You need to read it as character. I doubt that age is the only value in your data. When I made a small test file that is tab delimited with just name and age columns, I was able to read the age value correctly by using the program shown below:
Hope this helps,
Cynthia
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.