<?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: Using macros to import 3 excel files located in the same folder in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/432112#M68703</link>
    <description>&lt;OL&gt;&lt;LI&gt;Create a data step and use PIPE to get the list of files in the directory, then you can filter out to get only excel files.&lt;/LI&gt;&lt;LI&gt;Now you can create a simple macro function to import the data from a sample excel file&lt;OL&gt;&lt;LI&gt;(use filename as in a macro variable)&lt;/LI&gt;&lt;LI&gt;Use a dummy data set when creating the import to SAS&lt;/LI&gt;&lt;LI&gt;Have check for the first run (Check if the final DS exists, if not then create it using data step or proc sql create)&lt;/LI&gt;&lt;LI&gt;on each step append the imported data to the above final data set&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;Then run a data _null_ statement and call the step 2 created macro in the data step and pass the file name to it.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;This is coad-able and simple and dynamic, it will work for more than 3 excels as well.&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jan 2018 08:54:10 GMT</pubDate>
    <dc:creator>Satish_Parida</dc:creator>
    <dc:date>2018-01-30T08:54:10Z</dc:date>
    <item>
      <title>Using macros to import 3 excel files located in the same folder</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/432056#M68701</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having trouble using a macro to import 3 excel files located in the same folder. I have found a couple of examples online. I tried using about 4 different ways. But it does not give me an output. Can someone explain how to do so and the logistics behind each step? Some seem pretty extensive, which I don't understand because for what&amp;nbsp;I see on the book, it seems that macros are used to reduce repetition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 05:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/432056#M68701</guid>
      <dc:creator>aespinarey</dc:creator>
      <dc:date>2018-01-30T05:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using macros to import 3 excel files located in the same folder</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/432060#M68702</link>
      <description>&lt;P&gt;Pick one you want, post what you’ve tried here, explain what doesn’t work and we’ll help you through it. Otherwise, the SAS macro appendix has a macro reference library and the first is how to import all csv files but it can be easily adapted for XLSX files.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One thing - before you write a macro, have working code to accomplish at least your base case. From there you identify the parts that are dynamic, such as file name and you can start creating a macro.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro tutorial&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro appendix&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n1qvxz5u3uru7yn1nk7q64ohvwak.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n1qvxz5u3uru7yn1nk7q64ohvwak.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;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/190090"&gt;@aespinarey&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am having trouble using a macro to import 3 excel files located in the same folder. I have found a couple of examples online. I tried using about 4 different ways. But it does not give me an output. Can someone explain how to do so and the logistics behind each step? Some seem pretty extensive, which I don't understand because for what&amp;nbsp;I see on the book, it seems that macros are used to reduce repetition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 05:12:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/432060#M68702</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-30T05:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using macros to import 3 excel files located in the same folder</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/432112#M68703</link>
      <description>&lt;OL&gt;&lt;LI&gt;Create a data step and use PIPE to get the list of files in the directory, then you can filter out to get only excel files.&lt;/LI&gt;&lt;LI&gt;Now you can create a simple macro function to import the data from a sample excel file&lt;OL&gt;&lt;LI&gt;(use filename as in a macro variable)&lt;/LI&gt;&lt;LI&gt;Use a dummy data set when creating the import to SAS&lt;/LI&gt;&lt;LI&gt;Have check for the first run (Check if the final DS exists, if not then create it using data step or proc sql create)&lt;/LI&gt;&lt;LI&gt;on each step append the imported data to the above final data set&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;Then run a data _null_ statement and call the step 2 created macro in the data step and pass the file name to it.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;This is coad-able and simple and dynamic, it will work for more than 3 excels as well.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 08:54:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/432112#M68703</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2018-01-30T08:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using macros to import 3 excel files located in the same folder</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/432598#M68723</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;I found a backbone to my macro. I think it may be working, but I am not sure as SAS log is no longer giving me feedback. It was giving me feedback with errors; then I changed a couple of things&amp;nbsp;and now the only feedback it is giving me is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"NOTE: The quoted string currently being processed has become more than 262 bytes long. You&lt;BR /&gt;might have unbalanced quotation marks."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the program I used:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;***********PART A:IMPORT FILES USING MACROS***********;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;****** 1. Get file lists in the directory*;&lt;BR /&gt;filename dirlist pipe 'dir "C:\HW5"\';&lt;/P&gt;&lt;P&gt;****** 2. Resolve file names to SAS dataset "files" *;&lt;BR /&gt;data files;&lt;BR /&gt;length fname $9;&lt;BR /&gt;infile dirlist truncover length= reclen;&lt;BR /&gt;input fname $varying9. reclen;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;****** 3. Store the number of files we want to import into macro variable "nfile" *;&lt;BR /&gt;data _null_;&lt;BR /&gt;set files nobs= nobs;&lt;BR /&gt;call symput('nfile', nobs);&lt;BR /&gt;stop;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;******* 4. Import all the files we want into SAS dataset*;&lt;BR /&gt;%macro fileinput;&lt;BR /&gt;%local i;&lt;BR /&gt;%do i= 1 %to &amp;amp;nfile;&lt;BR /&gt;* Store import path and output filename into macro variables*;&lt;BR /&gt;data _null_;&lt;BR /&gt;set files(firstobs= &amp;amp;i obs= &amp;amp;i);&lt;BR /&gt;* The length of fpath can't be over 201 since windows limitation *;&lt;BR /&gt;call symput('fpath', "C:\HW5" || fname);&lt;BR /&gt;call symput('foutname', scan(fname, 1, '.') );&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;* Excel file import*;&lt;BR /&gt;proc import out= work.file.&amp;amp;foutname&lt;BR /&gt;datafile= "&amp;amp;fpath"&lt;BR /&gt;dbms=excel replace;&lt;BR /&gt;range="sheet1$";&lt;BR /&gt;getnames=yes;&lt;BR /&gt;mixed=no;&lt;BR /&gt;scantext=yes;&lt;BR /&gt;usedate=yes;&lt;BR /&gt;scantime=yes;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%fileinput;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 03:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/432598#M68723</guid>
      <dc:creator>aespinarey</dc:creator>
      <dc:date>2018-01-31T03:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using macros to import 3 excel files located in the same folder</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/432599#M68724</link>
      <description>&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;I tried the program below; however, I am not sure if it has done anything. The only feedback the log is giving me is "NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;***********PART A:IMPORT FILES USING MACROS***********;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;****** 1. Get file lists in the directory*;&lt;BR /&gt;filename dirlist pipe 'dir "C:\HW5"\';&lt;/P&gt;&lt;P&gt;****** 2. Resolve file names to SAS dataset "files" *;&lt;BR /&gt;data files;&lt;BR /&gt;length fname $9;&lt;BR /&gt;infile dirlist truncover length= reclen;&lt;BR /&gt;input fname $varying9. reclen;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;****** 3. Store the number of files we want to import into macro variable "nfile" *;&lt;BR /&gt;data _null_;&lt;BR /&gt;set files nobs= nobs;&lt;BR /&gt;call symput('nfile', nobs);&lt;BR /&gt;stop;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;******* 4. Import all the files we want into SAS dataset*;&lt;BR /&gt;%macro fileinput;&lt;BR /&gt;%local i;&lt;BR /&gt;%do i= 1 %to &amp;amp;nfile;&lt;BR /&gt;* Store import path and output filename into macro variables*;&lt;BR /&gt;data _null_;&lt;BR /&gt;set files(firstobs= &amp;amp;i obs= &amp;amp;i);&lt;BR /&gt;* The length of fpath can't be over 201 since windows limitation *;&lt;BR /&gt;call symput('fpath', "C:\HW5" || fname);&lt;BR /&gt;call symput('foutname', scan(fname, 1, '.') );&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;* Excel file import*;&lt;BR /&gt;proc import out= work.file.&amp;amp;foutname&lt;BR /&gt;datafile= "&amp;amp;fpath"&lt;BR /&gt;dbms=excel replace;&lt;BR /&gt;range="sheet1$";&lt;BR /&gt;getnames=yes;&lt;BR /&gt;mixed=no;&lt;BR /&gt;scantext=yes;&lt;BR /&gt;usedate=yes;&lt;BR /&gt;scantime=yes;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%fileinput;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 03:29:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/432599#M68724</guid>
      <dc:creator>aespinarey</dc:creator>
      <dc:date>2018-01-31T03:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using macros to import 3 excel files located in the same folder</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/432634#M68727</link>
      <description>&lt;P&gt;Try Importing a single file with the sample import first before trying to automate the thing.&lt;BR /&gt;If there is an issue in single file reading then post the log here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have made some modifications to your code for all file reading, hope it will help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename dirlist pipe 'dir "C:\HW5"\';

data files;
length fname $9;
infile dirlist truncover length= reclen;
input fname $varying9. reclen;
run;

%macro fileinput(csvfile=);
	proc import out= workingset
	datafile= "&amp;amp;csvfile"
	dbms=excel replace;
	range="sheet1$";		*Not nesseasry ;
	getnames=yes;
	mixed=no;
	scantext=yes;
	usedate=yes;
	scantime=yes;
	run;

	%if %sysfunc(exist(workingset_finale)) %then %do;
		proc append base=workingset_finale data=workingset;
			 Run; 
	%end;

	%else %do;
		data workingset_finale;
			set workingset;
		run;
	%end;
%mend;

data _null_;
set files nobs= nobs;
call execute('fileinput(csvfile='||fname||');');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Jan 2018 08:45:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/432634#M68727</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2018-01-31T08:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using macros to import 3 excel files located in the same folder</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/433750#M68818</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I imported only 1 file without macros and it worked. The log response was&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;NOTE: The import data set has 49 observations and 5 variables.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;NOTE: WORK.DATAFILE1 data set was successfully created.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;NOTE: PROCEDURE IMPORT used (Total process time):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;real time 0.25 seconds&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;cpu time 0.01 seconds&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Then I ran the macro again and got this as the log response:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;NOTE: The infile DIRLIST is:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Unnamed Pipe Access Device,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;PROCESS=dir "C:\HW5"\,RECFM=V,LRECL=32767&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;NOTE: 12 records were read from the infile DIRLIST.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;The minimum record length was 0.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;The maximum record length was 53.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;NOTE: The data set WORK.FILES has 12 observations and 1 variables.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;NOTE: DATA statement used (Total process time):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;real time 0.09 seconds&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;cpu time 0.01 seconds&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt;I am trying to import 3 files and all files have more than 30 observations. I am not sure what it is referring to when it says &lt;FONT color="#0000FF"&gt;"&lt;SPAN&gt;NOTE: The data set WORK.FILES has 12 observations and 1 variables."&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;The following is the whole program after the changes you had suggested.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;****** 1. Get file lists in the directory*;&lt;BR /&gt;filename dirlist pipe 'dir "C:\HW5"\';&lt;/P&gt;&lt;P&gt;****** 2. Resolve file names to SAS dataset "files" *;&lt;BR /&gt;data files;&lt;BR /&gt;length fname $9;&lt;BR /&gt;infile dirlist truncover length= reclen;&lt;BR /&gt;input fname $varying9. reclen;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;******* 4. Import all the files we want into SAS dataset*;&lt;BR /&gt;%macro fileinput (csvfile=);&lt;/P&gt;&lt;P&gt;* Excel file import*;&lt;BR /&gt;proc import out= workingset&lt;BR /&gt;datafile= "&amp;amp;csvfile"&lt;BR /&gt;dbms=xlsx replace;&lt;BR /&gt;range="sheet1$";&lt;BR /&gt;run;&lt;BR /&gt;%if %sysfunc(exist(workingset_finale)) %then %do;&lt;BR /&gt;proc append base=workingset_finale data=workingset;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%else %do;&lt;BR /&gt;data workingset_finale;&lt;BR /&gt;set workingset;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;data _null_;&lt;BR /&gt;set files nobs= nobs;&lt;BR /&gt;call execute ('fileinput(csvfile='||fname||');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 02:50:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/433750#M68818</guid>
      <dc:creator>aespinarey</dc:creator>
      <dc:date>2018-02-03T02:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using macros to import 3 excel files located in the same folder</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/433755#M68821</link>
      <description>&lt;P&gt;The macro didn't execute that's the log from the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;****** 1. Get file lists in the directory*;&lt;BR /&gt;filename dirlist pipe 'dir "C:\HW5"\';&lt;BR /&gt;****** 2. Resolve file names to SAS dataset "files" *;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;data files;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;length fname $9;&lt;BR /&gt;infile dirlist truncover length= reclen;&lt;BR /&gt;input fname $varying9. reclen;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;NOTE: The data set &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;WORK.FILES&lt;/FONT&gt;&lt;/STRONG&gt; has 12 observations and 1 variables.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Your last data _null_ step is incorrect, you're missing the % for the macro call.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This code below is&amp;nbsp;redundant. PROC APPEND doesn't require the base data set to exist already so you can use PROC APPEND directly.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%if %sysfunc(exist(workingset_finale)) %then %do; &lt;FONT color="#FF0000"&gt;*delete;&lt;/FONT&gt;&lt;BR /&gt;proc append base=workingset_finale data=workingset;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;FONT color="#FF0000"&gt;*delete;&lt;/FONT&gt;&lt;BR /&gt;%else %do;&lt;FONT color="#FF0000"&gt;*delete;&lt;/FONT&gt;&lt;BR /&gt;data workingset_finale;&lt;FONT color="#FF0000"&gt;*delete;&lt;/FONT&gt;&lt;BR /&gt;set workingset;&lt;FONT color="#FF0000"&gt;*delete;&lt;/FONT&gt;&lt;BR /&gt;run;&lt;FONT color="#FF0000"&gt;*delete;&lt;/FONT&gt;&lt;BR /&gt;%end;&lt;FONT color="#FF0000"&gt;*delete;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;Why are you calling the macro parameter CSVFILE when it's XLSX?&lt;/FONT&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;Also, this is unlikely to work in the long run. When SAS imports an Excel file it has to guess at types, and it often guesses wrong. So this means that in one file a variable will be read as character and in another it will be read as numeric. When this happens you won't be able to append the data sets together so you'll need to first verify the types and correct for this.&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 04:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/433755#M68821</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-03T04:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using macros to import 3 excel files located in the same folder</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/433756#M68822</link>
      <description>&lt;P&gt;PS. When testing a macro, &amp;nbsp;make sure to call it manually first so you can see if the macro is not working or if the CALL EXECUTE step isn't working.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 04:14:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/433756#M68822</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-03T04:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using macros to import 3 excel files located in the same folder</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/433816#M68827</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;I found another way without using pipeline. It worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt; one (a, b, c);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc import out= &amp;amp;a&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;datafile= "C:\HW5\&amp;amp;b"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dbms=xlsx replace;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;getnames=yes;&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;proc sort data=&amp;amp;a;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;by &amp;amp;c;&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;STRONG&gt;%mend&lt;/STRONG&gt; one;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;EM&gt;one&lt;/EM&gt;&lt;/STRONG&gt; (datafile1, datafile1.xlsx, id);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;EM&gt;one&lt;/EM&gt;&lt;/STRONG&gt; (datafile2, datafile2.xlsx, id);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;EM&gt;one&lt;/EM&gt;&lt;/STRONG&gt; (datafile3, datafile3.xlsx, id);&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt; print_this (one);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Proc print data = &amp;amp;one;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Run;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt; print_this;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;EM&gt;print_this&lt;/EM&gt;&lt;/STRONG&gt; (DATAFILE1);&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;EM&gt;print_this&lt;/EM&gt;&lt;/STRONG&gt; (DATAFILE2);&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;EM&gt;print_this&lt;/EM&gt;&lt;/STRONG&gt; (DATAFILE3);&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 17:03:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/433816#M68827</guid>
      <dc:creator>aespinarey</dc:creator>
      <dc:date>2018-02-03T17:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using macros to import 3 excel files located in the same folder</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/433843#M68828</link>
      <description>&lt;P&gt;Yes, pipes were being used to find the list of files. If you know where they are or don't need to automate that step you can skip it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Glad you have your problem solved, please mark the question as solved. Since your solution is the one that worked, you can set that as the answer.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 20:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-macros-to-import-3-excel-files-located-in-the-same-folder/m-p/433843#M68828</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-03T20:19:39Z</dc:date>
    </item>
  </channel>
</rss>

