<?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 to access Census Trade data in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-to-access-Census-Trade-data/m-p/985015#M46452</link>
    <description>&lt;P&gt;Look at the RESP file to see the error message that the API you are querying generated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Two things.&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;There does not appear to be a variable named&amp;nbsp;&lt;SPAN&gt;I_COMMODIT that you are requesting.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;It does not like the spaces in the GET= option.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;Also it looks like it includes all of the extra variables you mention in the filters, so you can remove&amp;nbsp;I_COMMODITY from the list of variables provided to GET=.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename resp temp;

proc http
&amp;nbsp; method="get"
&amp;nbsp; url='https://api.census.gov/data/timeseries/intltrade/imports/hs'
&amp;nbsp; query=(&amp;nbsp; &amp;nbsp; 
"get" = "CTY_CODE,CTY_NAME,CON_QY1_MO,I_COMMODITY_SDESC,GEN_VAL_MO"
"COMM_LVL" = "HS10"
"YEAR"="2025"
"MONTH"="01"
"I_COMMODITY"="76*"
&amp;nbsp; )
&amp;nbsp; verbose
&amp;nbsp; out=resp
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Once you have the file it looks like you can read it simply by just removing the square brackets.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 infile resp dsd firstobs=2 truncover  ;
 input @;
 _infile_=compress(_infile_,'[]');
 input (CTY_CODE CTY_NAME CON_QY1_MO I_COMMODITY_SDESC GEN_VAL_MO COMM_LVL YEAR MONTH I_COMMODITY)
       (:$100.)
 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Mar 2026 18:06:04 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2026-03-19T18:06:04Z</dc:date>
    <item>
      <title>PROC HTTP to access Census Trade data</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-to-access-Census-Trade-data/m-p/984978#M46448</link>
      <description>&lt;P&gt;Hello Gurus,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to run following code to access publicly available Census data -&amp;nbsp; I get BAD request.&amp;nbsp; &amp;nbsp;When I paste URL in chrome,&amp;nbsp; it gets me the data.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thanks in advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;proc http&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; method="get"&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; url='&lt;A href="https://api.census.gov/data/timeseries/intltrade/imports/hs" target="_blank"&gt;https://api.census.gov/data/timeseries/intltrade/imports/hs&lt;/A&gt;'&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; query=(&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; "get" = "CTY_CODE,CTY_NAME,CON_QY1_MO,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I_COMMODITY,I_COMMODITY_SDESC,I_COMMODIT,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;GEN_VAL_MO"&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; "COMM_LVL" = "HS10"&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; "YEAR"="2025"&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; "MONTH"="01"&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; "I_COMMODITY" = "76*"&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; )&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; verbose&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; out=resp&lt;/DIV&gt;
&lt;DIV&gt;;&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;URL:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://api.census.gov/data/timeseries/intltrade/imports/hs?get=CON_QY1_MO,CTY_CODE,CTY_NAME,I_COMMODITY,I_COMMODITY_SDESC,UNIT_QY1,GEN_VAL_MO&amp;amp;YEAR=2025&amp;amp;MONTH=01&amp;amp;COMM_LVL=HS10&amp;amp;I_COMMODITY=76*" target="_blank"&gt;https://api.census.gov/data/timeseries/intltrade/imports/hs?get=CON_QY1_MO,CTY_CODE,CTY_NAME,I_COMMODITY,I_COMMODITY_SDESC,UNIT_QY1,GEN_VAL_MO&amp;amp;YEAR=2025&amp;amp;MONTH=01&amp;amp;COMM_LVL=HS10&amp;amp;I_COMMODITY=76*&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2026 18:54:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-to-access-Census-Trade-data/m-p/984978#M46448</guid>
      <dc:creator>BhargavDesai</dc:creator>
      <dc:date>2026-03-18T18:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP to access Census Trade data</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-to-access-Census-Trade-data/m-p/984985#M46449</link>
      <description>&lt;P&gt;Best practice on this forum is to show us the LOG generated when submitting the code. The exact wording of error or warning messages is important as they often include important clues as to possible solutions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest that you re-run the code and if the issue persists to copy from the log the code and all messages related to proc http. On the forum open a text box using the &amp;lt;/&amp;gt; icon that appears above the message window and paste the copied text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't show a definition for the OUT=resp. Somewhere prior to this you should have a Filename statement creating a reference to a file that the "get" will write to for later processing.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2026 19:53:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-to-access-Census-Trade-data/m-p/984985#M46449</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2026-03-18T19:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP to access Census Trade data</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-to-access-Census-Trade-data/m-p/984987#M46450</link>
      <description>&lt;P&gt;Adding debug level=3; shows an error in one of the parameters:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;lt; 0000020F76230395: 65 72 72 6F 72 3A 20 75 6E 6B 6E 6F 77 6E 20 76 error: unknown v
&amp;lt; 0000020F762303A5: 61 72 69 61 62 6C 65 20 27 49 5F 43 4F 4D 4D 4F ariable 'I_COMMO
&amp;lt; 0000020F762303B5: 44 49 54 27                                     DIT'
&lt;/PRE&gt;
&lt;P&gt;When I copy the exact URL string that you're using with Chrome, it works ok:&lt;/P&gt;
&lt;PRE&gt;filename resp temp;                                                                                                                             
%let parms=?get=CON_QY1_MO,CTY_CODE,CTY_NAME,I_COMMODITY,I_COMMODITY_SDESC,UNIT_QY1,GEN_VAL_MO&amp;amp;YEAR=2025&amp;amp;MONTH=01&amp;amp;COMM_LVL=HS10&amp;amp;I_COMMODITY=76*;
proc http                                                                                                                                       
  method="get"                                                                                                                                  
  url="https://api.census.gov/data/timeseries/intltrade/imports/hs&amp;amp;parms"                                                                       
  verbose                                                                                                                                       
  out=resp                                                                                                                                      
;                                                                                                                                               
run;
&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Mar 2026 20:28:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-to-access-Census-Trade-data/m-p/984987#M46450</guid>
      <dc:creator>DaveHorne</dc:creator>
      <dc:date>2026-03-18T20:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP to access Census Trade data</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-to-access-Census-Trade-data/m-p/984992#M46451</link>
      <description>&lt;P&gt;Interesting .&lt;/P&gt;
&lt;P&gt;Although there is an ERROR in your LOG.&lt;/P&gt;
&lt;PRE&gt;5    proc http
6      method="get"
7      url='https://api.census.gov/data/timeseries/intltrade/imports/hs?get=CON_QY1_MO,CTY_CODE,CTY_NAME,I_COMMODITY,I_COMMODITY_SDESC,UNIT_QY1,GEN_VA
7  ! L_MO&amp;amp;YEAR=2025&amp;amp;MONTH=01&amp;amp;COMM_LVL=HS10&amp;amp;I_COMMODITY=76*'
8      verbose
9     out=out
10    headerout=hdrout;
URL                  =
https://api.census.gov/data/timeseries/intltrade/imports/hs?get=CON_QY1_MO,CTY_CODE,CTY_NAME,I_COMMODITY,I_COMMODITY_SDESC,UNIT_QY1,GEN_VAL_MO&amp;amp;YEAR=20
25&amp;amp;MONTH=01&amp;amp;COMM_LVL=HS10&amp;amp;I_COMMODITY=76*
METHOD               = get
Out                  = c:\temp\Output.txt
Header Out           = c:\temp\Response.txt

11   debug level=3;
12   run;

ERROR: 连接至“148.129.75.191:443”时出错。(连接超时。)
ERROR: 无法连接 Web 服务器。
&lt;/PRE&gt;
&lt;P&gt;But the json file you want to download is already in there , check this:&lt;/P&gt;
&lt;PRE&gt;filename out&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt; "c:\temp\Output.txt";&lt;/STRONG&gt;&lt;/FONT&gt;
 
filename hdrout "c:\temp\Response.txt";

proc http                                                                                                                                       
  method="get"                                                                                                                                  
  url='https://api.census.gov/data/timeseries/intltrade/imports/hs?get=CON_QY1_MO,CTY_CODE,CTY_NAME,I_COMMODITY,I_COMMODITY_SDESC,UNIT_QY1,GEN_VAL_MO&amp;amp;YEAR=2025&amp;amp;MONTH=01&amp;amp;COMM_LVL=HS10&amp;amp;I_COMMODITY=76*'                                                                    
  verbose                                                                                                                                       
 out=out
 headerout=hdrout;
debug level=3;                                                                                                                                               
run;
&lt;/PRE&gt;
&lt;P&gt;Therefore you could ignore this ERROR info I guess.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="屏幕截图 2026-03-19 154253.png" style="width: 978px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/113692i99FF05F973892D8C/image-size/large?v=v2&amp;amp;px=999" role="button" title="屏幕截图 2026-03-19 154253.png" alt="屏幕截图 2026-03-19 154253.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2026 07:47:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-to-access-Census-Trade-data/m-p/984992#M46451</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2026-03-19T07:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP to access Census Trade data</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-to-access-Census-Trade-data/m-p/985015#M46452</link>
      <description>&lt;P&gt;Look at the RESP file to see the error message that the API you are querying generated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Two things.&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;There does not appear to be a variable named&amp;nbsp;&lt;SPAN&gt;I_COMMODIT that you are requesting.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;It does not like the spaces in the GET= option.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;Also it looks like it includes all of the extra variables you mention in the filters, so you can remove&amp;nbsp;I_COMMODITY from the list of variables provided to GET=.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename resp temp;

proc http
&amp;nbsp; method="get"
&amp;nbsp; url='https://api.census.gov/data/timeseries/intltrade/imports/hs'
&amp;nbsp; query=(&amp;nbsp; &amp;nbsp; 
"get" = "CTY_CODE,CTY_NAME,CON_QY1_MO,I_COMMODITY_SDESC,GEN_VAL_MO"
"COMM_LVL" = "HS10"
"YEAR"="2025"
"MONTH"="01"
"I_COMMODITY"="76*"
&amp;nbsp; )
&amp;nbsp; verbose
&amp;nbsp; out=resp
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Once you have the file it looks like you can read it simply by just removing the square brackets.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 infile resp dsd firstobs=2 truncover  ;
 input @;
 _infile_=compress(_infile_,'[]');
 input (CTY_CODE CTY_NAME CON_QY1_MO I_COMMODITY_SDESC GEN_VAL_MO COMM_LVL YEAR MONTH I_COMMODITY)
       (:$100.)
 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2026 18:06:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-to-access-Census-Trade-data/m-p/985015#M46452</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-03-19T18:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP to access Census Trade data</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-to-access-Census-Trade-data/m-p/985039#M46453</link>
      <description>Thanks.  I will try them out</description>
      <pubDate>Fri, 20 Mar 2026 14:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-to-access-Census-Trade-data/m-p/985039#M46453</guid>
      <dc:creator>BhargavDesai</dc:creator>
      <dc:date>2026-03-20T14:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP to access Census Trade data</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-to-access-Census-Trade-data/m-p/985513#M46458</link>
      <description>Hello,&lt;BR /&gt;I think you have to put the entire endpoint into the quoted URL string (I've never used a "Query" option in PROC HTTP before). i.e., url='&lt;A href="https://api.census.gov/data/timeseries/intltrade/imports/hs?get=CON_QY1_MO,CTY_CODE,CTY_NAME,I_COMMODITY,I_COMMODITY_SDESC,UNIT_QY1,GEN_VAL_MO&amp;amp;YEAR=2025&amp;amp;MONTH=01&amp;amp;COMM_LVL=HS10&amp;amp;I_COMMODITY=76*" target="_blank"&gt;https://api.census.gov/data/timeseries/intltrade/imports/hs?get=CON_QY1_MO,CTY_CODE,CTY_NAME,I_COMMODITY,I_COMMODITY_SDESC,UNIT_QY1,GEN_VAL_MO&amp;amp;YEAR=2025&amp;amp;MONTH=01&amp;amp;COMM_LVL=HS10&amp;amp;I_COMMODITY=76*&lt;/A&gt;'</description>
      <pubDate>Fri, 27 Mar 2026 15:06:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-to-access-Census-Trade-data/m-p/985513#M46458</guid>
      <dc:creator>LukeDalton</dc:creator>
      <dc:date>2026-03-27T15:06:41Z</dc:date>
    </item>
  </channel>
</rss>

