BookmarkSubscribeRSS Feed
Calcite | Level 5

I'm new to this concept and I was wondering if you could help me. 


I have successfully used PROC HTTP to call data from a website. the problem is that I'm only able to call single Portfolio id each time (this is how the API is set up). 


I was wondering if you could help me change this code to use hypothetical Table A column B values (all 150+ values) to feed into the below code as portfolio ids and eventually create a table with results from using these portfolio ids. 


%let AccessKey =/*Enter Token id Here*/;
%let Portfoli_id =/*Enter Portfolio id Here*/;
proc http

method="GET" out=FS;
"Authorization"="Bearer &AccessKey.";

libname PP Json fileref=FS;
proc contents data=PP._all_;


Really appreciate your help!

Quartz | Level 8

I've done something similar for posting to an API one at a time. Instead of using %let to set your variables, use data null with call symputx. You'll need a count variable to know how many times to loop. Use that count number to know which observation in your dataset to grab. Hope this is helpful. 


/*After the dataset is created, figure out the count you'll need to loop through*/ 
data _null_; call symputx('cnt',&sysnobs.); run; /*compile APILoop macro*/ %macro APILoop(); %do i=1 %to &cnt.; /*Create needed variables you'll pass into the loop - one at a time*/ data _null_; set table_A (firstobs=&i. obs=&i.); call symputx('AccessKey',AccessKey); call symputx('Portfoli_id',Portfoli_id); run; /*Now you have the variables created to put into your proc http*/ proc http; /*insert code here*/ run; %end; %mend; /*Run Loop*/ %APILoop()



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
  • 1 reply
  • 1 like
  • 2 in conversation