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;
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).
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).
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.
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.