BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Biobee
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
7 REPLIES 7
MikeZdeb
Rhodochrosite | Level 12

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;

Linlin
Lapis Lazuli | Level 10

Hi MIke,

What is the '/' for between the two lines?

@16 gender         $1.

/

@07 dob            mmddyy10.


Thanks!

Biobee
Calcite | Level 5

Hi Linlin,

the / is for SAS to recognise that the record has continued on the next line.

cheers

Biobee

MikeZdeb
Rhodochrosite | Level 12

hi Linlin ... it means move to a new record in the file being read

Linlin
Lapis Lazuli | Level 10

Thank you Mike!!!

Biobee
Calcite | Level 5

Your code works like a charm.

MikeZdeb
Rhodochrosite | Level 12

hi ... so is it merely "helpful" or is it "correct" ... inquiring minds would like to know

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 1059 views
  • 4 likes
  • 3 in conversation