BookmarkSubscribeRSS Feed
rboire
Calcite | Level 5

Is there simple base SAS programming that read in the following JSON type data. See below example.

 

{

Tenure: 2 spend: 5  

}

{

 tenure:6 products:4 region:PQ spend:7

}

{

Credit score:100 region:ont tenure:7 country:can

}

{

Credit score:50 country:US

}

{

Tenure:5 region:US spend:100 creditscore:300

}

   

2 REPLIES 2
ballardw
Super User

Which version of SAS are you running?

Ksharp
Super User

I notice some "Credit score" have blanks in it, but the last one is not . which one is real world ?

Assuming there is no blank in it.

NOTE: if you have SAS9.4 M4 , best choice is libname + JSON engine.

 

data x;
 infile '/folders/myfolders/xxxx.json' lrecl=300000  dlm='}: ';
 input x : $200. @@;
run;
data want;;
 merge x x(firstobs=2 rename=(x=value));
 if x=:'{' then do;x=substr(x,2); id+1;end;
 if mod(_n_,2)=1;
run;
proc print noobs;run;

x.png

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 945 views
  • 0 likes
  • 3 in conversation