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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register 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.

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
  • 553 views
  • 0 likes
  • 3 in conversation