<?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: Need help to create table which includes API call in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-table-which-includes-API-call/m-p/886651#M350361</link>
    <description>&lt;P&gt;Your initial select&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;select market_id into :mkt_typ_id&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from abc&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where id in ('100');&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;only selects one record.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So I assume your API call only matches one record.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Try deleting the WHERE clause.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jul 2023 15:05:09 GMT</pubDate>
    <dc:creator>HB</dc:creator>
    <dc:date>2023-07-27T15:05:09Z</dc:date>
    <item>
      <title>Need help to create table which includes API call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-table-which-includes-API-call/m-p/886639#M350350</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I am new for API calls , wanted to understand how can I create a table&lt;/P&gt;
&lt;P&gt;I have table like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;table &lt;STRONG&gt;abc&lt;/STRONG&gt;&lt;BR /&gt;id market_id&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; 100&lt;BR /&gt;2&amp;nbsp; &amp;nbsp;500&lt;BR /&gt;4&amp;nbsp; &amp;nbsp;600&lt;BR /&gt;3&amp;nbsp; &amp;nbsp;300&lt;BR /&gt;5&amp;nbsp; &amp;nbsp;400&lt;/P&gt;
&lt;P&gt;I have one more table xyz table, in a different database , where we can do only API call to get data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;table &lt;STRONG&gt;xyz&lt;/STRONG&gt;&lt;BR /&gt;market_id&amp;nbsp; &amp;nbsp;market_cd&lt;BR /&gt;100&amp;nbsp; &amp;nbsp; 12&lt;BR /&gt;500&amp;nbsp; &amp;nbsp; 13&lt;BR /&gt;300&amp;nbsp; &amp;nbsp;22&lt;BR /&gt;600&amp;nbsp; &amp;nbsp;55&lt;BR /&gt;700&amp;nbsp; &amp;nbsp;44&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am doing API call like this to get market_cd.&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;BR /&gt;select market_id into :mkt_typ_id&lt;BR /&gt;from abc&lt;BR /&gt;where id in ('100'); &lt;BR /&gt;quit;&lt;BR /&gt;%put &amp;amp;mkt_typ_id;&lt;/P&gt;
&lt;P&gt;proc http&lt;BR /&gt;url="&amp;amp;SERVICESBASEURL./&amp;amp;mkt_typ_id"&lt;BR /&gt;method="GET"&lt;BR /&gt;out=resp2&lt;BR /&gt;OAUTH_BEARER = SAS_SERVICES;&lt;BR /&gt;run;&lt;BR /&gt;libname resp2 json fileref=resp2;&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;BR /&gt;select trim(code) into: market_cd from resp2.root&lt;BR /&gt;where lowcase(memberId)= "&amp;amp;mkt_typ_id";&lt;BR /&gt;quit;&lt;BR /&gt;%put &amp;amp;market_cd;&lt;/P&gt;
&lt;P&gt;-- here I am getting only one value for market_cd that is 12.&lt;/P&gt;
&lt;P&gt;But I want to create a table like table three as mentioned below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;table &lt;STRONG&gt;three&lt;/STRONG&gt;&lt;BR /&gt;&lt;EM&gt;id&amp;nbsp; market_cd&lt;/EM&gt;&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; 12&lt;BR /&gt;2&amp;nbsp; &amp;nbsp; 13&lt;BR /&gt;4&amp;nbsp; &amp;nbsp;55&lt;BR /&gt;3&amp;nbsp; &amp;nbsp;22&lt;/P&gt;
&lt;P&gt;Can anyone please help , How to achieve this.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2023 13:58:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-table-which-includes-API-call/m-p/886639#M350350</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2023-07-27T13:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to create table which includes API call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-table-which-includes-API-call/m-p/886651#M350361</link>
      <description>&lt;P&gt;Your initial select&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;select market_id into :mkt_typ_id&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from abc&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where id in ('100');&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;only selects one record.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So I assume your API call only matches one record.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Try deleting the WHERE clause.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2023 15:05:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-table-which-includes-API-call/m-p/886651#M350361</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2023-07-27T15:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to create table which includes API call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-table-which-includes-API-call/m-p/886653#M350363</link>
      <description>&lt;P&gt;I don't understand.&lt;/P&gt;
&lt;P&gt;Is the issue that each API call can only return one value?&lt;/P&gt;
&lt;P&gt;Or is the issue that last SQL step that is only pulling one value from the JSON response that the API returned?&lt;/P&gt;
&lt;P&gt;If the later then don't use a macro variable to get the data from the JSON file. Just use normal SAS code instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the former then you just need to do it one at a time.&amp;nbsp; You can use PROC APPEND or the PROC SQL INSERT statement to append the results into one dataset.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2023 15:21:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-table-which-includes-API-call/m-p/886653#M350363</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-27T15:21:14Z</dc:date>
    </item>
  </channel>
</rss>

