<?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 Multiple Get API Calls into One File in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Get-API-Calls-into-One-File/m-p/805511#M317322</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to call an API that only accepts one argument at a time. I want to call it about 100 times. I have my code set up so that the returned data is saved into a txt file "resp". Currently, every time I call the API, the "resp" file is replaced. I would rather each call's returned data be appended to the file.&lt;/P&gt;&lt;P&gt;Here is my code so far: (I will add in an array of ids eventually)&lt;/P&gt;&lt;PRE&gt;%MACRO callapi (id=);
proc http
url ="api/url/etc"
method="get"
out=resp;
run;
%MEND callapi;
%callapi(id=id1);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess one solution would be to create a new folder and have every response create a new file and append them afterwards, but I'd rather not do that if I don't have to.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 01 Apr 2022 14:33:03 GMT</pubDate>
    <dc:creator>xLoreleix</dc:creator>
    <dc:date>2022-04-01T14:33:03Z</dc:date>
    <item>
      <title>Multiple Get API Calls into One File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Get-API-Calls-into-One-File/m-p/805511#M317322</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to call an API that only accepts one argument at a time. I want to call it about 100 times. I have my code set up so that the returned data is saved into a txt file "resp". Currently, every time I call the API, the "resp" file is replaced. I would rather each call's returned data be appended to the file.&lt;/P&gt;&lt;P&gt;Here is my code so far: (I will add in an array of ids eventually)&lt;/P&gt;&lt;PRE&gt;%MACRO callapi (id=);
proc http
url ="api/url/etc"
method="get"
out=resp;
run;
%MEND callapi;
%callapi(id=id1);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess one solution would be to create a new folder and have every response create a new file and append them afterwards, but I'd rather not do that if I don't have to.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 14:33:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Get-API-Calls-into-One-File/m-p/805511#M317322</guid>
      <dc:creator>xLoreleix</dc:creator>
      <dc:date>2022-04-01T14:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Get API Calls into One File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Get-API-Calls-into-One-File/m-p/805553#M317336</link>
      <description>&lt;P&gt;I assume that you're going to take that txt file and convert it to SAS data, correct? So in your macro, add a DATA step that reads the file and creates a data set with a new name (work.data_01, work.data_02, etc.). You can then later append the data sets together when you're all done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use this technique all of the time. Alternatively, you could use the FILENAME statement to remap&amp;nbsp;&lt;STRONG&gt;resp&lt;/STRONG&gt; to a new file before each call, maybe placing into a file like "data_01.txt", "data_02.txt", etc. Then finish with a DATA step that uses INFILE with a wildcard notation to read all of the data at once.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 17:56:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Get-API-Calls-into-One-File/m-p/805553#M317336</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2022-04-01T17:56:12Z</dc:date>
    </item>
  </channel>
</rss>

