<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: PROC HTTP - Macro loop or any other methods! in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-Macro-loop-or-any-other-methods/m-p/633335#M77874</link>
    <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*After the dataset is created, figure out the count you'll need to loop through*/ &lt;BR /&gt;data _null_; 
call symputx('cnt',&amp;amp;sysnobs.); 
run; 

/*compile APILoop macro*/ 
%macro APILoop(); 

%do i=1 %to &amp;amp;cnt.;  
/*Create needed variables you'll pass into the loop - one at a time*/
data _null_;
set table_A (firstobs=&amp;amp;i. obs=&amp;amp;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()&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 19 Mar 2020 16:01:28 GMT</pubDate>
    <dc:creator>bobpep212</dc:creator>
    <dc:date>2020-03-19T16:01:28Z</dc:date>
    <item>
      <title>PROC HTTP - Macro loop or any other methods!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-Macro-loop-or-any-other-methods/m-p/633303#M77871</link>
      <description>&lt;DIV class="NoteView lia-note-view-display lia-note-source-outbox lia-note-read lia-read lia-component-notes-widget-note-view lia-component-note"&gt;&lt;DIV class="lia-quilt lia-quilt-private-notes-item lia-quilt-layout-single-row-full"&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-main"&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-24 lia-quilt-column-single lia-quilt-column-main-content"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-single"&gt;&lt;DIV class="lia-note-content"&gt;&lt;DIV class="lia-note-body lia-component-body"&gt;&lt;P&gt;I'm new to this concept and I was wondering if you could help me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let AccessKey =/*Enter Token id Here*/;&lt;BR /&gt;%let Portfoli_id =/*Enter Portfolio id Here*/;&lt;BR /&gt;proc http&lt;BR /&gt;url="url/&amp;amp;Portfoli_id"&lt;/P&gt;&lt;P&gt;method="GET" out=FS;&lt;BR /&gt;headers&lt;BR /&gt;"Authorization"="Bearer &amp;amp;AccessKey.";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;libname PP Json fileref=FS;&lt;BR /&gt;proc contents data=PP._all_;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Really appreciate your help!&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="lia-menu-bar lia-menu-bar-bottom bottom-block lia-component-menubar-pager-bottom"&gt;&lt;DIV class="lia-decoration-border-menu-bar"&gt;&lt;DIV class="lia-decoration-border-menu-bar-content"&gt;&lt;DIV&gt;&lt;DIV class="lia-paging-full-wrapper"&gt;&lt;UL&gt;&lt;LI&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 19 Mar 2020 15:04:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-Macro-loop-or-any-other-methods/m-p/633303#M77871</guid>
      <dc:creator>Kaveh</dc:creator>
      <dc:date>2020-03-19T15:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP - Macro loop or any other methods!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-Macro-loop-or-any-other-methods/m-p/633335#M77874</link>
      <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*After the dataset is created, figure out the count you'll need to loop through*/ &lt;BR /&gt;data _null_; 
call symputx('cnt',&amp;amp;sysnobs.); 
run; 

/*compile APILoop macro*/ 
%macro APILoop(); 

%do i=1 %to &amp;amp;cnt.;  
/*Create needed variables you'll pass into the loop - one at a time*/
data _null_;
set table_A (firstobs=&amp;amp;i. obs=&amp;amp;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()&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Mar 2020 16:01:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-Macro-loop-or-any-other-methods/m-p/633335#M77874</guid>
      <dc:creator>bobpep212</dc:creator>
      <dc:date>2020-03-19T16:01:28Z</dc:date>
    </item>
  </channel>
</rss>

