<?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: How to Import .csv file from URL in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/937162#M11337</link>
    <description>&lt;P&gt;That is also a good example of one of the problems with using PROC IMPORT to guess how to read a CSV file.&amp;nbsp; PROC IMPORT will assume that ZIP_CODE should be numeric since it only sees digit strings in that column.&amp;nbsp; For this particular file it causes less issue since none of the zipcodes that are present start with a zero digit.&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jul 2024 17:48:19 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-07-25T17:48:19Z</dc:date>
    <item>
      <title>How to Import .csv file from URL</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/925622#M11248</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;&lt;P&gt;I have a URL of India Stock exchange which download .CSV file.&lt;BR /&gt;I want to import this .CSV file from &lt;A title="Download CSV file" href="https://www.nseindia.com/api/live-analysis-variations?index=gainers&amp;amp;type=FOSec&amp;amp;csv=true" target="_self"&gt;URL&lt;/A&gt; and load in to dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While running below code, code is continuously running and no result is producing.&lt;BR /&gt;do not know if code is running or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.csv File size is very small approx 1700 KB.,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;filename csvFile url "https://www.nseindia.com/api/live-analysis-variations?index=gainers&amp;amp;type=FOSec&amp;amp;csv=true" termstr=crlf;
proc import datafile=csvFile out=work.hello replace dbms=csv;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 18:17:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/925622#M11248</guid>
      <dc:creator>Riteshdell</dc:creator>
      <dc:date>2024-04-24T18:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to Import .csv file from URL</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/925653#M11249</link>
      <description>&lt;P&gt;Does that URL work for you?&amp;nbsp; I just get a webpage that says Resource not found&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even if it did work I doubt that PROC IMPORT can deal with reading directly from a fileref created using URL engine. It cannot even read from a file using the ZIP engine.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either copy the file to an actual file. Using a data step or PROC HTTP and then use PROC IMPORT to read from there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or use some other method to guess how to convert the CSV file into a dataset.&amp;nbsp; Such as&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/csv2ds.sas" target="_self"&gt;https://github.com/sasutils/macros/blob/master/csv2ds.sas&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 19:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/925653#M11249</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-24T19:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to Import .csv file from URL</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/925654#M11250</link>
      <description>&lt;P&gt;Have you tried using PROC HTTPS to download the file and then import it instead?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename _myfile "/home/reeza/api_data.csv";
 
proc http method="get" 
 url="https://www.nseindia.com/api/live-analysis-variations?index=gainers&amp;amp;type=FOSec&amp;amp;csv=true"
 out=_myfile
;
run;
 
filename _myfile clear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FYI your URL does go to URL not found so it's not a valid URL either....probably need to fix that first.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/6813"&gt;@Riteshdell&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;I have a URL of India Stock exchange which download .CSV file.&lt;BR /&gt;I want to import this .CSV file from &lt;A title="Download CSV file" href="https://www.nseindia.com/api/live-analysis-variations?index=gainers&amp;amp;type=FOSec&amp;amp;csv=true" target="_self"&gt;URL&lt;/A&gt; and load in to dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While running below code, code is continuously running and no result is producing.&lt;BR /&gt;do not know if code is running or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;.csv File size is very small approx 1700 KB.,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;filename csvFile url "https://www.nseindia.com/api/live-analysis-variations?index=gainers&amp;amp;type=FOSec&amp;amp;csv=true" termstr=crlf;
proc import datafile=csvFile out=work.hello replace dbms=csv;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 19:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/925654#M11250</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-04-24T19:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to Import .csv file from URL</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/925660#M11251</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let src='https://gist.githubusercontent.com/rnirmal/e01acfdaf54a6f9b24e91ba4cae63518/raw/6b589a5c5a851711e20c5eb28f9d54742d1fe2dc/datasets.csv';
filename samp '/home/fkhurshed/Demo1/sample.csv';

proc http url=&amp;amp;src out=samp method=get;
run;


proc import datafile=samp out=want dbms=csv replace;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Apr 2024 20:27:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/925660#M11251</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-04-24T20:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to Import .csv file from URL</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/925665#M11252</link>
      <description>&lt;P&gt;That is an interesting example file for demonstrating some of the issues with PROC IMPORT for CSV files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First without specifying GUESSINGROWS=MAX it will truncate some of the strings for the variable ABOUT.&lt;/P&gt;
&lt;PRE&gt;Obs    _TYPE_     _OBS_                                      about

 1     BASE         23     SaudiNewsNet Collection of Saudi Newspaper Articles (Arabic, 30K articles)
 2     COMPARE      23     SaudiNewsNet Collection of Saudi Newspaper Articles (Arabic,
 3     DIF          23     .............................................................XXX.XXXXXXXXX
 4     BASE         26     Cheng-Caverlee-Lee September 2009 - January 2010 Twitter Scrape
 5     COMPARE      26     Cheng-Caverlee-Lee September 2009 - January 2010 Twitter Scra
 6     DIF          26     .............................................................XX...........
 7     BASE         54     Simple but fast reverse geocoding up to city granularitiy level
 8     COMPARE      54     Simple but fast reverse geocoding up to city granularitiy lev
 9     DIF          54     .............................................................XX...........

&lt;/PRE&gt;
&lt;P&gt;And even when you fix that it calculates the length needed for some of the characters variables wrong.&amp;nbsp; And also attached unneeded (and undesirable) formats and informats to the variables.&lt;/P&gt;
&lt;PRE&gt;Listing of Common Variables with Differing Attributes

Variable      Dataset    Type  Length  Format  Informat

datasetName   WORK.SAMP  Char      26
              WORK.WANT  Char      62  $62.    $62.
about         WORK.SAMP  Char      74
              WORK.WANT  Char      76  $76.    $76.
link          WORK.SAMP  Char     105
              WORK.WANT  Char     105  $105.   $105.
categoryName  WORK.SAMP  Char      25
              WORK.WANT  Char      25  $25.    $25.
cloud         WORK.SAMP  Char       6
              WORK.WANT  Char       6  $6.     $6.
vintage       WORK.SAMP  Char       4
              WORK.WANT  Char       4  $4.     $4.
&lt;/PRE&gt;
&lt;P&gt;It got the length of ABOUT wrong because it counted the quotes added around one value to protect an embedded comma.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I cannot figure out how to heck it got the length of DATASETNAME so wrong.&amp;nbsp; I suspect it was caused by the single quotes in line 20, but that is just a guess.&lt;/P&gt;
&lt;PRE&gt;1528  options generic;
1529  filename samp2 temp;
1530  data _null_;
1531    infile samp;
1532    file samp2;
1533    input;
1534    if _n_=1 or indexc(_infile_,"'");
1535    put _infile_;
1536    list;
1537  run;

NOTE: The infile SAMP is:
      (system-specific pathname),
      (system-specific file attributes)

NOTE: The file SAMP2 is:
      (system-specific pathname),
      (system-specific file attributes)

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
1         datasetName,about,link,categoryName,cloud,vintage 49
14        TwoFishes,TwoFishes - Foursquare's coarse geocoder,https://github.com/foursquare/twofishes,GIS,GitHu
     101  b,NA 104
20        Cooper-Hewitt's Collection,Cooper-Hewitt's Collection Database,https://github.com/cooperhewitt/colle
     101  ction,Museums,GitHub,NA 123
31        Skytrax' Air,Skytrax' Air Travel Reviews Dataset,https://github.com/quankiquanki/skytrax-reviews-dat
     101  aset,Social Networks,GitHub,NA 130
49        USDA PLANTS,U.S. Department of Agriculture's PLANTS Database,http://www.plants.usda.gov/dl_all.html,
     101  Agriculture,,NA 115
NOTE: 62 records were read from the infile (system-specific pathname).
      The minimum record length was 49.
      The maximum record length was 181.
NOTE: 5 records were written to the file (system-specific pathname).
      The minimum record length was 49.
      The maximum record length was 130.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Apr 2024 20:59:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/925665#M11252</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-24T20:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to Import .csv file from URL</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/925682#M11253</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/6813"&gt;@Riteshdell&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The url you shared doesn't work for me (Resource not found).&lt;/P&gt;
&lt;P&gt;You need to embed any url that contains macro tokens &amp;amp; and % into single quotes for the macro processor not trying to resolve these tokens.&lt;/P&gt;
&lt;P&gt;It also appears that the&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsglobal/p103pi2vrzn6qhn1e8alrs01jrb7.htm#p1dk46kj0i13pyn1olqcy54vle7g" target="_self"&gt;FILENAME Statement: URL Access Method&lt;/A&gt; only works for urls without parameters and where you've got the actual file name.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1714012564644.png" style="width: 1055px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95845iF20C601773E3F41B/image-dimensions/1055x232?v=v2" width="1055" height="232" role="button" title="Patrick_0-1714012564644.png" alt="Patrick_0-1714012564644.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If you've got a valid url Proc Http as proposed by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;will work.&lt;/P&gt;
&lt;P&gt;Using Proc Http has also the advantage that you can inspect the downloaded file and write a SAS data step /infile/input that gives you full control over how you read the external file into a SAS data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;It appears that if the url is suitable for the url access method then things also work with Proc Import.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let url='https://support.sas.com/documentation/onlinedoc/viya/exampledatasets/account.csv';

filename csvFile url &amp;amp;url debug;
proc import 
  datafile=csvFile 
  out=work.hello 
  replace 
  dbms=csv;
  guessingrows=max;
run;
filename csvFile clear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I also found that when using the EG Import wizard there were no variables with unnecessary lengths.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 02:38:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/925682#M11253</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-04-25T02:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to Import .csv file from URL</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/937157#M11335</link>
      <description>&lt;P&gt;The following scripts work perfectly. Hope this is helpful.&lt;/P&gt;&lt;P&gt;filename pop_raw temp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc http&lt;BR /&gt;url="&lt;A href="https://data.lacity.org/api/views/nxs9-385f/rows.csv?accessType=DOWNLOAD" target="_blank"&gt;https://data.lacity.org/api/views/nxs9-385f/rows.csv?accessType=DOWNLOAD&lt;/A&gt;"&lt;BR /&gt;method="GET"&lt;BR /&gt;out=pop_raw;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc import datafile=pop_raw dbms=csv replace&lt;BR /&gt;out=pop;&lt;BR /&gt;guessingrows=max;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 17:31:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/937157#M11335</guid>
      <dc:creator>jayzhao</dc:creator>
      <dc:date>2024-07-25T17:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to Import .csv file from URL</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/937161#M11336</link>
      <description>&lt;P&gt;PROC IMPORT will try to read the file twice (it first reads the file to determine variable names and&amp;nbsp;&lt;EM&gt;make guesses&lt;/EM&gt; about variable types/informats/formats, then creates a DATA step to do the actual import.&lt;/P&gt;
&lt;P&gt;Write the DATA step yourself, according to the documentation on the website, and see what happens when you submit it.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 17:47:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/937161#M11336</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-07-25T17:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to Import .csv file from URL</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/937162#M11337</link>
      <description>&lt;P&gt;That is also a good example of one of the problems with using PROC IMPORT to guess how to read a CSV file.&amp;nbsp; PROC IMPORT will assume that ZIP_CODE should be numeric since it only sees digit strings in that column.&amp;nbsp; For this particular file it causes less issue since none of the zipcodes that are present start with a zero digit.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 17:48:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-Import-csv-file-from-URL/m-p/937162#M11337</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-07-25T17:48:19Z</dc:date>
    </item>
  </channel>
</rss>

