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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Registration is open
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss. Register now and lock in 2025 pricing—just $495!