BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Jacek2
Obsidian | Level 7
 

I have text:

[{crmId: 270294251239318446711736, zapłacone faktury:0}, {crmId: 109338771587264730348439, zapłacone faktury:0}, {crmId: 105563037561893625234667, zapłacone faktury:0}, {crmId: 529342335726661326310295, zapłacone faktury:0}, {crmId: 102928808219759468645267, zapłacone faktury:0}, {crmId: 446627936599178084266781, zapłacone faktury:0}, {crmId: 1206246190076409102049055, zapłacone faktury:0}, {crmId: 1208925742523269613394857, zapłacone faktury:0}]

 

I want crmid:

270294251239318446711736

109338771587264730348439

105563037561893625234667

529342335726661326310295

102928808219759468645267

446627936599178084266781

1206246190076409102049055

1208925742523269613394857

 

In this case is 7 id in new row but their number and length may vary

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data have;
have="[{crmId: 270294251239318446711736, zapłacone faktury:0}, {crmId: 109338771587264730348439, zapłacone faktury:0}, {crmId: 105563037561893625234667, zapłacone faktury:0}, {crmId: 529342335726661326310295, zapłacone faktury:0}, {crmId: 102928808219759468645267, zapłacone faktury:0}, {crmId: 446627936599178084266781, zapłacone faktury:0}, {crmId: 1206246190076409102049055, zapłacone faktury:0}, {crmId: 1208925742523269613394857, zapłacone faktury:0}]";
run;

data want;
 set have;
 pid=prxparse('/(?<=crmId:)\s*\d+/i');
 s=1;e=length(have);
 call prxnext(pid,s,e,have,p,l);
 do while(p>0);
   crmId=substr(have,p,l);
   output;
   call prxnext(pid,s,e,have,p,l);
 end;
 keep crmId;
run;

View solution in original post

4 REPLIES 4
Jacek2
Obsidian | Level 7
no, it's a text variable from work.table
Ksharp
Super User
data have;
have="[{crmId: 270294251239318446711736, zapłacone faktury:0}, {crmId: 109338771587264730348439, zapłacone faktury:0}, {crmId: 105563037561893625234667, zapłacone faktury:0}, {crmId: 529342335726661326310295, zapłacone faktury:0}, {crmId: 102928808219759468645267, zapłacone faktury:0}, {crmId: 446627936599178084266781, zapłacone faktury:0}, {crmId: 1206246190076409102049055, zapłacone faktury:0}, {crmId: 1208925742523269613394857, zapłacone faktury:0}]";
run;

data want;
 set have;
 pid=prxparse('/(?<=crmId:)\s*\d+/i');
 s=1;e=length(have);
 call prxnext(pid,s,e,have,p,l);
 do while(p>0);
   crmId=substr(have,p,l);
   output;
   call prxnext(pid,s,e,have,p,l);
 end;
 keep crmId;
run;
Jacek2
Obsidian | Level 7
Thank you, it works very well !!!

sas-innovate-2024.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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
  • 4 replies
  • 328 views
  • 1 like
  • 3 in conversation