BookmarkSubscribeRSS Feed
sunayana67
Calcite | Level 5

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;

 

 

Screenshot 2021-05-30 at 6.16.27 PM.png

 

Can anyone help me out with how I can read that record? 

3 REPLIES 3
Astounding
PROC Star

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.

ChrisNZ
Tourmaline | Level 20

Please change the title to something meaningful.

Ksharp
Super User


data Company;
infile "c:\temp\company.txt" dlm = '$' dsd truncover termstr=lf;
input LastName $ EmpNo $ Salary;
run;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1453 views
  • 1 like
  • 4 in conversation