BookmarkSubscribeRSS Feed
R_Win
Calcite | Level 5
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
3 REPLIES 3
Flip
Fluorite | Level 6
Search on 'delimited input" you will find things such as
http://support.sas.com/techsup/technote/ts673.html
deleted_user
Not applicable
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 ;
Flip
Fluorite | Level 6
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;

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1472 views
  • 0 likes
  • 3 in conversation