Help using Base SAS procedures

Moving the output to new variabble after '\'

Reply
Regular Contributor
Posts: 229

Moving the output to new variabble after '\'

i have a variable in that observation there are \ after that it shd move to another variable

data jl;
input id;
cards;
16516\646465
146416
6546546\546205
516884
1654685\261656
run;


Now i want the out put like this the observation after the \ shd be moved to another variable the output shd be

id id2
16516 646465
146416
6546546 546205
516884
1654685 261656
Super Contributor
Posts: 359

Re: Moving the output to new variabble after '\'

Search on 'delimited input" you will find things such as
http://support.sas.com/techsup/technote/ts673.html
N/A
Posts: 0

Re: Moving the output to new variabble after '\'

You could do it this way:

data dataset ;
set jl ;
if index(id,'\') then
do ;
id2=substr(id,prxmatch("/\\/",id)+1,30) ;
id=substr(id,1,prxmatch("/\\/",id)-1) ;
end ;
run ;
Super Contributor
Posts: 359

Re: Moving the output to new variabble after '\'

Simpler would be,

data jl;
input id $15. ;

id1 = scan(id,1, '\');
id2 = scan(id, 2, '\');
id1n = input(id1, best.);
id2n = input(id2, best.);
cards;
16516\646465
146416
6546546\546205
516884
1654685\261656
run;
Ask a Question
Discussion stats
  • 3 replies
  • 87 views
  • 0 likes
  • 3 in conversation