<?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 append while import CSV files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745734#M233822</link>
    <description>&lt;P&gt;The import is working well.&lt;/P&gt;
&lt;P&gt;The source files are without CSV end .&lt;/P&gt;
&lt;P&gt;But they are with delimiter ;&lt;/P&gt;
&lt;P&gt;As I said the import is working well but the proc append not&lt;/P&gt;</description>
    <pubDate>Fri, 04 Jun 2021 11:40:24 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2021-06-04T11:40:24Z</dc:date>
    <item>
      <title>proc append while import CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745724#M233814</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I am using proc append while import CSV files.&lt;/P&gt;
&lt;P&gt;What is the reason that proc append is not working?&lt;/P&gt;
&lt;P&gt;I am checking and dataset&amp;nbsp; tbl_All was not created?&lt;/P&gt;
&lt;P&gt;What is the correct code to do it please?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro import_one(YYYYMMDD);
%if %sysfunc(fileexist(/path/Revenue&amp;amp;YYYYMMDD.))
%then %do;
data tbl&amp;amp;YYYYMMDD.;
infile "path/Revenue&amp;amp;YYYYMMDD."
dlm=';' dsd truncover firstobs=2;
input VAR1-VAR59;
run;
%end;
%else %do;
data tbl&amp;amp;YYYYMMDD.;
Format VAR1-VAR59 8.;
stop;
run;
%end;

proc append base=tbl_All  data=tbl&amp;amp;YYYYMMDD. force; run; quit;
proc delete data=tbl&amp;amp;YYYYMMDD.;Run;

%mend import_one;
Data datestbl;
input YYYYMMDD $;
call execute('%nrstr(%import_one('!!YYYYMMDD!!'))');
cards;
20191231
20210101
20210102
20210103
20210104
20210105
;
Run;
 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Jun 2021 11:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745724#M233814</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-06-04T11:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: proc append while import CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745725#M233815</link>
      <description>&lt;P&gt;Maxim 2: Read the Log.&lt;/P&gt;
&lt;P&gt;If that does not give you a sufficient clue, post the log here.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 11:21:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745725#M233815</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-04T11:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: proc append while import CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745726#M233816</link>
      <description>&lt;P&gt;The filenames are different here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysfunc(fileexist(/path/RevenueA&amp;amp;YYYYMMDD.))
%then %do;
data tbl&amp;amp;YYYYMMDD.;
infile "path/Revenue&amp;amp;YYYYMMDD."&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the INFILE statement, there is no leading slash, and no A before the date, but both are present in the FILEEXIST call.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 11:24:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745726#M233816</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-04T11:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: proc append while import CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745727#M233817</link>
      <description>&lt;P&gt;Log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not see any file extension such as CSV in your FILEEXIST or INFILE statements. Which is pretty suspect.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 11:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745727#M233817</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-04T11:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: proc append while import CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745730#M233818</link>
      <description>NOTE: Appending WORK.tbl20210105 to WORK.tbl_ALL.&lt;BR /&gt;WARNING: Variable VAR1 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR2 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR3 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR4 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR5 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR6 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR7 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR8 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR9 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR10 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR11 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR12 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR13 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR14 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR15 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR16 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR17 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR18 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR19 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR20 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR21 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR22 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR23 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR24 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR25 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR26 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR27 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR28 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR29 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR30 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR31 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR32 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR33 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR34 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR35 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR36 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR37 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR38 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR39 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR40 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR41 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR42 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR43 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR44 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR45 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR46 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR47 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR48 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR49 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR50 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR51 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR52 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR53 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR54 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR55 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR56 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR57 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;21                                                         The SAS System                                 13:55 Friday, June 4, 2021&lt;BR /&gt;&lt;BR /&gt;WARNING: Variable VAR58 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;WARNING: Variable VAR59 was not found on BASE file. The variable will not be added to the BASE file.&lt;BR /&gt;NOTE: FORCE is specified, so dropping/truncating will occur.&lt;BR /&gt; &lt;BR /&gt;INFO: Engine's fast-append process in use.&lt;BR /&gt;INFO: 14:30:58 Reading DATA file, updating BASE file&lt;BR /&gt;INFO: Starting data set size is 2 pages&lt;BR /&gt;INFO: Ending data set size is 2 pages, 0 added.&lt;BR /&gt;INFO: 00:00:00 Elapsed time&lt;BR /&gt;INFO: 14:30:58 Finished updating BASE file&lt;BR /&gt; &lt;BR /&gt;NOTE: There were 3781 observations read from the data set WORK.tbl20210105.&lt;BR /&gt;NOTE: 3781 observations added.&lt;BR /&gt;NOTE: The data set WORK.tbl_ALL has 75625 observations and 0 variables.&lt;BR /&gt;NOTE: PROCEDURE APPEND used (Total process time):&lt;BR /&gt;      real time           0.00 seconds&lt;BR /&gt;      user cpu time       0.00 seconds&lt;BR /&gt;      system cpu time     0.00 seconds&lt;BR /&gt;      memory              1505.71k&lt;BR /&gt;      OS Memory           26284.00k&lt;BR /&gt;      Timestamp           06/04/2021 02:30:58 PM&lt;BR /&gt;      Step Count                        310  Switch Count  0&lt;BR /&gt;      Page Faults                       0&lt;BR /&gt;      Page Reclaims                     148&lt;BR /&gt;      Page Swaps                        0&lt;BR /&gt;      Voluntary Context Switches        6&lt;BR /&gt;      Involuntary Context Switches      0&lt;BR /&gt;      Block Input Operations            0&lt;BR /&gt;      Block Output Operations           0&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Jun 2021 11:34:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745730#M233818</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-06-04T11:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: proc append while import CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745733#M233821</link>
      <description>&lt;P&gt;Thank you, I have changed the tables names because I cannot copy names from my work.&lt;/P&gt;
&lt;P&gt;The import is running well .&lt;/P&gt;
&lt;P&gt;IF the CSV file exists then a data set is created (with rows and columns).&lt;/P&gt;
&lt;P&gt;IF the CSV file doesnt exist then an empty data set is created with 0 rows and columns .&lt;/P&gt;
&lt;P&gt;In both cases columns are same (VAR-VAR59 with same attributes: all numerical).&lt;/P&gt;
&lt;P&gt;The proc append is not working.&lt;/P&gt;
&lt;P&gt;May anyone know why?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 11:39:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745733#M233821</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-06-04T11:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: proc append while import CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745734#M233822</link>
      <description>&lt;P&gt;The import is working well.&lt;/P&gt;
&lt;P&gt;The source files are without CSV end .&lt;/P&gt;
&lt;P&gt;But they are with delimiter ;&lt;/P&gt;
&lt;P&gt;As I said the import is working well but the proc append not&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 11:40:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745734#M233822</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-06-04T11:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: proc append while import CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745738#M233823</link>
      <description>&lt;P&gt;You seem to already have a BASE dataset that does not contain your variables. Make sure that this dataset does not exist before you run your code.&lt;/P&gt;
&lt;P&gt;Also, while developing/debugging, comment the PROC DELETE, so you can inspect the intermediate files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if your goal is to read a sequence of csv files into one dataset, you can do that in a single data step by using the FILEVAR= option of the INFILE statement and a loop for reading each file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set datestbl;
fname = "/path/revenue" !! yymmdd;
if fileexist(fname)
then do;
  infile dummy filevar=fname dlm="," dsd truncover end=done;
  do until (done);
    input var1-var59;
    output;
  end;
end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 11:48:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745738#M233823</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-04T11:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: proc append while import CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745746#M233830</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you, I have changed the tables names because I cannot copy names from my work.&lt;/P&gt;
&lt;P&gt;The import is running well .&lt;/P&gt;
&lt;P&gt;IF the CSV file exists then a data set is created (with rows and columns).&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;IF the CSV file doesnt exist then an empty data set is created with 0 rows and columns .&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;In both cases columns are same (VAR-VAR59 with same attributes: all numerical).&lt;/P&gt;
&lt;P&gt;The proc append is not working.&lt;/P&gt;
&lt;P&gt;May anyone know why?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You need to make sure the empty datasets have the exact same structure as the other datasets.&lt;/P&gt;
&lt;P&gt;I showed you how to modify the placement of the %IF block in the middle of the data step so that the empty datasets have the same structure as the other datasets in your other thread.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 11:59:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745746#M233830</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-04T11:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: proc append while import CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745836#M233883</link>
      <description>&lt;P&gt;To prevent the step from stopping on the first empty file switch from UNTIL() to WHILE().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do while (not done);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Jun 2021 16:15:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745836#M233883</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-04T16:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: proc append while import CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745867#M233906</link>
      <description>&lt;P&gt;You are perfectly right.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 17:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745867#M233906</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-04T17:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: proc append while import CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745975#M233944</link>
      <description>&lt;P&gt;Now this is working,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro import_one(YYYYMMDD);
%if %sysfunc(fileexist(/path/Revenue&amp;amp;YYYYMMDD.))
%then %do;
data Revenue;
infile "path/Revenue&amp;amp;YYYYMMDD."
dlm=';' dsd truncover firstobs=2;
input VAR1-VAR59;
run;
%end;
%else %do;
data Revenue;
Format VAR1-VAR59 8.;
stop;
run;
%end;

proc append base=Revenue_All  data=Revenue  force; run; quit;
%mend import_one;
Data datestbl;
input YYYYMMDD $;
call execute('%nrstr(%import_one('!!YYYYMMDD!!'))');
cards;
20191231
20210101
20210102
20210103
20210104
20210105
;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 05 Jun 2021 09:09:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-append-while-import-CSV-files/m-p/745975#M233944</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-06-05T09:09:51Z</dc:date>
    </item>
  </channel>
</rss>

