<?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: Reading csv from share drive into sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-csv-from-share-drive-into-sas/m-p/431957#M106902</link>
    <description>&lt;P&gt;This error&lt;/P&gt;
&lt;PRE&gt;ERROR: Physical file does not exist, /myshare/HHFit/AL/AL_HHF_STM_ToState_20180129_01.csv.&lt;/PRE&gt;
&lt;P&gt;may be caused by running in a server environment as the path may need to be relative to the server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The macro language really doesn't make it simple to check for "blank" values. but this&lt;/P&gt;
&lt;PRE&gt;%Let cnt=1;
%Let Thisstate=%scan(&amp;amp;StateList, &amp;amp;cnt, %Str( ) );
%Do %While (&amp;amp;Thisstate NE );
&lt;/PRE&gt;
&lt;P&gt;could be replaced with something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%Let Listcnt= %sysfunct(countw(&amp;amp;StateList));
%do i = 1 %to &amp;amp;Listcount;
   %Let Thisstate=%scan(&amp;amp;StateList,&amp;amp;i );
&lt;/PRE&gt;
&lt;P&gt;and instead of incrementing the cnt variable and extracting thisstate just use %end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jan 2018 20:32:08 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-01-29T20:32:08Z</dc:date>
    <item>
      <title>Reading csv from share drive into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-csv-from-share-drive-into-sas/m-p/431928#M106889</link>
      <description>&lt;P&gt;I have a share drive with about 10 states named by folder (ie al az dc etc...)&amp;nbsp; Within those folders there may be a .csv file or may not be one.&lt;/P&gt;
&lt;P&gt;I am attempting to say if it exists import the contents of each folder into one dataset in sas.&amp;nbsp; Here is what I have so far&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; myPath =/myshare/HHFit;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;myPath;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%Let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; StateList= AL az ca dc ehlp FL ga il in ky&amp;nbsp; ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; fetchstates(Statelist= , Currdate= );&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%Let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; cnt=1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%Let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Thisstate=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;StateList, &amp;amp;cnt, &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%Str&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;( ) );&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%Do&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%While&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Thisstate NE );&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc import out= &amp;amp;Thisstate&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; datafile=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;myPath/&amp;amp;Thisstate./&amp;amp;Thisstate._HHF_STM_ToState_&amp;amp;Currdate_key._01.csv"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;dbms=CSV replace ;&lt;/P&gt;
&lt;P&gt;getnames=no;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; datarow=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/*** Advance counter and select next state ***/&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%Let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; cnt=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;cnt + 1);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%Let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Thisstate=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;StateList, &amp;amp;cnt, &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%Str&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;( ) );&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%End&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%Mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;fetchstates&lt;/I&gt;&lt;/STRONG&gt;(StateList=&amp;amp;StateList,&lt;/P&gt;
&lt;P&gt;Currdate=&amp;amp;Currdate_key);&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I get the following error.&amp;nbsp; It is unable to open the parameter and says file does not exists.&amp;nbsp; In some cases theres no file however theres a file for AL (Alabama).&amp;nbsp; The program is supposed to loop through all folders and grab the cvs if it exists.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SYMBOLGEN: Macro variable THISSTATE resolves to AL&lt;/P&gt;
&lt;P&gt;SYMBOLGEN: Macro variable DORSHHFPATH resolves to /myshare/HHFit&lt;/P&gt;
&lt;P&gt;SYMBOLGEN: Macro variable THISSTATE resolves to AL&lt;/P&gt;
&lt;P&gt;SYMBOLGEN: Macro variable THISSTATE resolves to AL&lt;/P&gt;
&lt;P&gt;SYMBOLGEN: Macro variable CURRDATE_KEY resolves to 20180129&lt;/P&gt;
&lt;P&gt;MPRINT(FETCHSTATES): proc import out= AL datafile="/myshare/HHFit/AL/AL_HHF_STM_ToState_20180129_01.csv" dbms=CSV replace ;&lt;/P&gt;
&lt;P&gt;MPRINT(FETCHSTATES): ADLM;&lt;/P&gt;
&lt;P&gt;MPRINT(FETCHSTATES): getnames=no;&lt;/P&gt;
&lt;P&gt;MPRINT(FETCHSTATES): datarow=3;&lt;/P&gt;
&lt;P&gt;MPRINT(FETCHSTATES): run;&lt;/P&gt;
&lt;P&gt;NOTE: Unable to open parameter catalog: SASUSER.PARMS.PARMS.SLIST in update mode. Temporary parameter values will be saved to WORK.PARMS.PARMS.SLIST.&lt;/P&gt;
&lt;P&gt;ERROR: Physical file does not exist, /myshare/HHFit/AL/AL_HHF_STM_ToState_20180129_01.csv.&lt;/P&gt;
&lt;P&gt;ERROR: Import unsuccessful. See SAS Log for details.&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;
&lt;P&gt;NOTE: PROCEDURE IMPORT used (Total process time):&lt;/P&gt;
&lt;P&gt;real time 0.11 seconds&lt;/P&gt;
&lt;P&gt;cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;Thisstate NE&lt;/P&gt;
&lt;P&gt;ERROR: The condition in the %DO %WHILE loop, , yielded an invalid or missing value, . The macro will stop executing.&lt;/P&gt;
&lt;P&gt;ERROR: The macro FETCHSTATES will stop executing.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 19:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-csv-from-share-drive-into-sas/m-p/431928#M106889</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2018-01-29T19:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: Reading csv from share drive into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-csv-from-share-drive-into-sas/m-p/431931#M106890</link>
      <description>&lt;P&gt;You need a modified version of this.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n0ctmldxf23ixtn1kqsoh5bsgmg8.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n0ctmldxf23ixtn1kqsoh5bsgmg8.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The appendix also has examples of looping through lists, though I'm partial to CALL EXECUTE myself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 19:51:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-csv-from-share-drive-into-sas/m-p/431931#M106890</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-29T19:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: Reading csv from share drive into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-csv-from-share-drive-into-sas/m-p/431957#M106902</link>
      <description>&lt;P&gt;This error&lt;/P&gt;
&lt;PRE&gt;ERROR: Physical file does not exist, /myshare/HHFit/AL/AL_HHF_STM_ToState_20180129_01.csv.&lt;/PRE&gt;
&lt;P&gt;may be caused by running in a server environment as the path may need to be relative to the server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The macro language really doesn't make it simple to check for "blank" values. but this&lt;/P&gt;
&lt;PRE&gt;%Let cnt=1;
%Let Thisstate=%scan(&amp;amp;StateList, &amp;amp;cnt, %Str( ) );
%Do %While (&amp;amp;Thisstate NE );
&lt;/PRE&gt;
&lt;P&gt;could be replaced with something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%Let Listcnt= %sysfunct(countw(&amp;amp;StateList));
%do i = 1 %to &amp;amp;Listcount;
   %Let Thisstate=%scan(&amp;amp;StateList,&amp;amp;i );
&lt;/PRE&gt;
&lt;P&gt;and instead of incrementing the cnt variable and extracting thisstate just use %end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 20:32:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-csv-from-share-drive-into-sas/m-p/431957#M106902</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-29T20:32:08Z</dc:date>
    </item>
  </channel>
</rss>

