DATA Step, Macro, Functions and more

Data Set Help

Accepted Solution Solved
Reply
Contributor SJN
Contributor
Posts: 21
Accepted Solution

Data Set Help

[ Edited ]

data birthinfo1;
length name $24. dob $12. sex $1.;
input name $24. dob $12. sex $1. ;
/*put _all_;*/
datalines;
james cathryn 15/10/1991 F
john Paul Mathew Pich 12/4/1964 M
Abharam Lincoln 25/12/1966 M
Lan 22/02/1956 F
run;

Can you please help me populatiing the data into above dataset.

 

Regards,

SJN


Accepted Solutions
Solution
‎07-01-2017 05:35 AM
Super User
Posts: 10,023

Re: Data Set Help

data birthinfo1;
input ;
name=substr(_infile_,1,anydigit(_infile_)-1);
dob=scan(_infile_,-2,' ');
sex=scan(_infile_,-1,' ');
datalines;
james cathryn 15/10/1991 F
john Paul Mathew Pich 12/4/1964 M
Abharam Lincoln 25/12/1966 M
Lan 22/02/1956 F
;
run;

View solution in original post


All Replies
Trusted Advisor
Posts: 1,560

Re: Data Set Help

Omit the dots at length statement.

The dots are needed in format statement.

data birthinfo1;
         length name $24 dob $12 sex $1;
input name $24. dob $12. sex $1. ;
/*put _all_;*/
datalines;
james cathryn 15/10/1991 F
john Paul Mathew Pich 12/4/1964 M
Abharam Lincoln 25/12/1966 M
Lan 22/02/1956 F
run;
Solution
‎07-01-2017 05:35 AM
Super User
Posts: 10,023

Re: Data Set Help

data birthinfo1;
input ;
name=substr(_infile_,1,anydigit(_infile_)-1);
dob=scan(_infile_,-2,' ');
sex=scan(_infile_,-1,' ');
datalines;
james cathryn 15/10/1991 F
john Paul Mathew Pich 12/4/1964 M
Abharam Lincoln 25/12/1966 M
Lan 22/02/1956 F
;
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 134 views
  • 0 likes
  • 3 in conversation