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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 672 views
  • 1 like
  • 2 in conversation