I have a dataset which is in the format that there are multiple lines per observation and the delimiter is a space between the columns. I have written a code to read in the dataset but I am having trouble reading it in properly. The issues I am facing are: 1. The DOB variable doesnot show the correct year of the people 2. I had to read in the SalaryStart and SalaryEnd as Character while I want to read it in as numeric. 3. The gender field has not been read in correctly. However, doing so yields only missing values. 3.Some of the values are getting mixed in different columns. I will really appreciate any help to straighten out my code. I have attached the dataset and the code to this message.
Thanks in advance,
Biobee
Message was edited by: Biobee bh
Your code works like a charm.
hi ... try this ...
data employment;
infile 'z:\employment.txt' truncover;
input
@01 name $17.
@20 startdate mmddyy10.
@36 salarystart comma7.
@43 enddate mmddyy10.
@58 salaryend comma7.
/
@01 maritalstatus $8.
@16 gender $1.
/
@07 dob mmddyy10.
;
format startdate enddate mmddyy10. dob worddate20. salary: dollar8.;
run;
proc print data=employment;
run;
Hi MIke,
What is the '/' for between the two lines?
@16 gender $1.
/
@07 dob mmddyy10.
Thanks!
Hi Linlin,
the / is for SAS to recognise that the record has continued on the next line.
cheers
Biobee
hi Linlin ... it means move to a new record in the file being read
Thank you Mike!!!
Your code works like a charm.
hi ... so is it merely "helpful" or is it "correct" ... inquiring minds would like to know
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.