**Fictional Content used**
Hello,
I'm trying to read in a staggered raw data file with various column widths but you see that I cannot successfully use a pointer
(i.e. @19 or +2) since the Employee_Name variable isn't a fixed column. How do I best achieve results such that they appear as expected?
RAW DATA
(Level1) Chief Executive Officer (Anthony Miller ) $433,800
(Level2) Chief Sales Officer (Harry Highpoint ) $243,190
(Level2) Chief Financial Officer (Max Crown ) $268,455
EXPECTED
Level Job_Title Employee_Name Salary
1 Chief Executive Officer Anthony Miller $433,800
2 Chief Sales Officer Harry Highpoint $243,190
2 Chief Financial Officer Max Crown $268,455
My code is as follows:
Work.Unicorn;
infile "rawin.dat" missover truncover;
length Level $ 8.;
input Level @;
if Level="(Level1)" then
input @10 Job_Title $25. @35 Employee_Name $18. @108 Salary dollar8.;
else if Level="(Level2)" then
input Job_Title $ +2;
run;
Thank you for any assistance,
David
Then please mark the answer which is closest to what you wanted as "correct" so that this question gets "ticked off" as answered.
You will need to get the informats right - but else below code should give you the idea.
data want;
infile datalines truncover dlm='()' dsd;
input dummy :$1 (Level Job_Title Employee_Name Salary) (:$20.);
datalines;
(Level1) Chief Executive Officer (Anthony Miller ) $433,800
(Level2) Chief Sales Officer (Harry Highpoint ) $243,190
(Level2) Chief Financial Officer (Max Crown ) $268,455
run;
I would read the first portion as a single text field and then parse it using the scan function with the () as delimiters.
Thank you all.
I overlooked using () as delimeters. Thanks for the info.
David
Then please mark the answer which is closest to what you wanted as "correct" so that this question gets "ticked off" as answered.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.