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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.