data a;
INPUT;
gender=scan(_infile_,-1,' ');
age=scan(_infile_,-2,' ');
call scan(_infile_,-2,p,l,' ');
name=substr(_infile_,1,p-1);
drop p l;
DATALINES;
RASPUTIN 45 M
BETSY ROSS 62 F
ROBERT LOUIS STEVENSON 75 M
;
data a;
INPUT;
gender=scan(_infile_,-1,' ');
age=scan(_infile_,-2,' ');
call scan(_infile_,-2,p,l,' ');
name=substr(_infile_,1,p-1);
drop p l;
DATALINES;
RASPUTIN 45 M
BETSY ROSS 62 F
ROBERT LOUIS STEVENSON 75 M
;
In addition to the solution given by @Ksharp, it can be solved without using SAS functions. The only requirement is that the value for NAME variable separated by two or more blanks as in:
data a;
INPUT NAME &$22. age gender $;
DATALINES;
RASPUTIN 45 M
BETSY ROSS 62 F
ROBERT LOUIS STEVENSON 75 M
;
run;
I introduced two BLANKS between NAME and AGE and used &$22 to read blank embedded NAME.
SAS Innovate 2025: Register Now
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9. Sign up by Dec. 31 to get the 2024 rate of just $495. Register now!