You are given a text file company.txt where dollar signs were used as delimiters. To indicate missing values, two dollars signs were entered. Values in this file represent last name, employee number, and annual salary.
Using this data file as input, create a SAS data set called Company with the variables LastName (character), EmpNo (character), and Salary (numeric).
I ran this program, in the log there is error while reading one of the records.
Code I used:
data Company;
infile "~/company.txt" dlm = '$';
input LastName $ EmpNo $ Salary;
run;
Can anyone help me out with how I can read that record?
In addition to using dsm='$' on the INFILE statement, add one more option: dsd
That's what tells SAS that each $ delimits a separate variable.
Please change the title to something meaningful.
data Company;
infile "c:\temp\company.txt" dlm = '$' dsd truncover termstr=lf;
input LastName $ EmpNo $ Salary;
run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.