BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
fatemeh
Quartz | Level 8

hello all,

I want to read this raw data ,that i attached here, in sas.But there is a problem in my coding i can not find the right start point for each variable when using @ in the input statement, also the length of each variable is not clear for me.Bellow is my code. Any help is appreciated !


data tempy;
infile "C:\Users\FATEMEH\Desktop\summer2017work\temp.txt";
input @1 dept$5.    @7 wagecat$1.    @8 wagerate 7.2     @16manager$7.    @23 jobtype 3.;
proc print data=tempy;run;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

It appears that your data is TAB delimited.

Try

data tempy;
   infile "C:\Users\FATEMEH\Desktop\summer2017work\temp.txt" dlm='09'x;
   informat  dept $5.  wagecat $1.   wagerate 7.2   manager $7.     jobtype 3.;
   input  dept    wagecat wagerate  manager  jobtype  ;
run;

I moved the informats to a separate line as they can cause issues when reading delimited text by forcing a read longer than the values that appear when the values have varying lengths such as your wagerate (5 to 7 ) and manager (4 to 7 characters).

 

View solution in original post

1 REPLY 1
ballardw
Super User

It appears that your data is TAB delimited.

Try

data tempy;
   infile "C:\Users\FATEMEH\Desktop\summer2017work\temp.txt" dlm='09'x;
   informat  dept $5.  wagecat $1.   wagerate 7.2   manager $7.     jobtype 3.;
   input  dept    wagecat wagerate  manager  jobtype  ;
run;

I moved the informats to a separate line as they can cause issues when reading delimited text by forcing a read longer than the values that appear when the values have varying lengths such as your wagerate (5 to 7 ) and manager (4 to 7 characters).

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

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
  • 1 reply
  • 1267 views
  • 1 like
  • 2 in conversation