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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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