**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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.