<?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 export dynamic datasets to file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/290057#M59959</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/91404"&gt;@Nancy05﻿&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post what you get from the put statement. It should be valid SAS code that you can copy and run. If it isn't then you have a mistake in your code, which you obviously do. It's most likely a semicolon error. And if you run the pasted copy SAS highlights the line that's the issue. As is, we're trying to guess. That's a waste of everyone's time. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is also why you should understand what your trying to do. So far I think your still using code that you don't understand which is dangerous and risky. Especially if you end up in a time crunch since you won't be able to modify it if needed. And it's unlikely you'll be able to reuse it either.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Aug 2016 00:03:47 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-08-08T00:03:47Z</dc:date>
    <item>
      <title>How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289397#M59766</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; for dynamic sql codes, now I would like to export all datasets to a file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the following code and got error. I am not quite sure how to correct "&amp;nbsp;set ELTML.memname;" clause in the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro print_report(CR_APPL_NO);
proc sql nonprint;
create table table_list as
select distinct memname
from sashelp.vtable
where libname ='ELTML' 
and upper(memname) like 'MLT%';
quit;

%*use Call execute to print each table for specified record;
%*I create the strings as an extra step to allow for debugging;
%*You should remove the PUT statements after you have this working;
data _null_;

SET TABLE_LIST;

str1=cats( "Title 'Mylending Tables-", upcase(memname), "';");
str2=cat("Proc Print Data=ELTML.", memname, "NOOBS;", "Where CR_APPL_NO=&amp;amp;CR_APPL_NO; RUN;");


call execute(str1);
call execute(str2);

data Mylending;
	set ELTML.memname;
Where CR_APPL_NO = &amp;amp;CR_APPL_NO;

proc export
 data=Mylending
 dbms=xlsx
 outfile="\\WLGFILE2\&amp;lt;path&amp;gt;\&amp;amp;CR_APPL_NO"
 replace;
RUN;

%mend;

%print_report(60048444);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;This is the error message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: File ELTML.MEMNAME.DATA does not exist.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I know this is incorrect, but i don't know how to make dataset dynamic and export the data to file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help is much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2016 23:52:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289397#M59766</guid>
      <dc:creator>Nancy05</dc:creator>
      <dc:date>2016-08-03T23:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289404#M59767</link>
      <description>&lt;P&gt;You need to use call execute again. You should generate another string that will resolve to the PROC EXPORT code that you need, I would recommend using a dataset WHERE option rather than creating datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your proc export would look something like the following.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export
 data=Mylending. memname (Where cntr_no=&amp;amp;cr_appl_no)
 dbms=xlsx
 outfile="\\WLGFILE2\&amp;lt;path&amp;gt;\&amp;amp;CR_APPL_NO"
 replace;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm not going to write the code because I believe you should understand the code your implementing/writing and this would show that you understand the concept.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The easiest way is to add a new variable STR3 that resolves to your proc export code above and then pass that to call execute.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code below should help you develop/test your string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let CR_APPL_NO=890234343;

proc sql nonprint;
create table table_list as
select distinct memname
from sashelp.vtable
where libname ='ELTML' 
and upper(memname) like 'MLT%';
quit;

%*use Call execute to print each table for specified record;
%*I create the strings as an extra step to allow for debugging;
%*You should remove the PUT statements after you have this working;
data commands;
SET TABLE_LIST;

str1=cats( "Title 'Mylending Tables-", upcase(memname), "';");
str2=cat("Proc Print Data=ELTML.", memname, "NOOBS;", "Where CR_APPL_NO=&amp;amp;CR_APPL_NO; RUN;");


*BUILD YOUR PROC EXPORT STRING HERE AS STR3;

*call execute(str1);
*call execute(str2);
*call execute(str3);

run;
&lt;/CODE&gt;&lt;/PRE&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2016 00:47:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289404#M59767</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-04T00:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289414#M59769</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;: Thanks for the code and suggestion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have added str3 shown below. but I&amp;nbsp;stuck with concatenation with quotation marks. How to&amp;nbsp;concatenation quotation mark " ?&lt;/P&gt;&lt;P&gt;Do you use "&amp;amp;"&amp;amp;" ? I googled but could not find the answer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro print_report(CR_APPL_NO);
proc sql nonprint;
create table table_list as
select distinct memname
from sashelp.vtable
where libname ='ELTML' 
and upper(memname) like 'MLT%';
quit;

%*use Call execute to print each table for specified record;
%*I create the strings as an extra step to allow for debugging;
%*You should remove the PUT statements after you have this working;
/*data _null_;*/
data commands;

SET TABLE_LIST;

str1=cats( "Title 'Mylending Tables-", upcase(memname), "';");
str2=cat("Proc Print Data=ELTML.", memname, "NOOBS;", "Where CR_APPL_NO=&amp;amp;CR_APPL_NO; RUN;");
str3=cat("Proc export data=ELTML.", memname, "(Where CR_APPL_NO=&amp;amp;CR_APPL_NO dbms=xlsx outfile outfile=","&amp;amp;"&amp;amp;","\\WLGFILE2\&amp;lt;path&amp;gt;\&amp;amp;CR_APPL_NO","&amp;amp;"&amp;amp;"," replace; RUN;"


call execute(str1);
call execute(str2);
call execute(str3);


%mend;

%print_report(60048444);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks&amp;nbsp;!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2016 02:35:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289414#M59769</guid>
      <dc:creator>Nancy05</dc:creator>
      <dc:date>2016-08-04T02:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289416#M59770</link>
      <description>&lt;P&gt;I've never been very good at the quotation marks portion myself.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Personally, I would assign a variable to the control number and then use that in my file path so I could use single quotes. You can sandwich single quotes between double quotes. Or you can try using 4 quotes. Or %str() or %nstr&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2016 02:58:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289416#M59770</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-04T02:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289437#M59780</link>
      <description>&lt;P&gt;Use a combination of single and double quotes to solve the problem&lt;/P&gt;
&lt;P&gt;eg&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let value1=yyy;
data _null_;
call execute("data test; set have; where x = '&amp;amp;value1';run;");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will create a data step&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set have;
where x = 'yyy';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;while&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let value1=yyy;
data _null_;
call execute('data test; set have; where x = "&amp;amp;value1"; run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will create&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set have;
where x = "&amp;amp;value1";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that the first version resolves value1 during the data_null_ step, while the second version will resolve value1 when the created data step is compiled.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2016 06:04:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289437#M59780</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-04T06:04:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289458#M59785</link>
      <description>&lt;P&gt;Sorry, I am looking at the code and it is not clear to me. &amp;nbsp;Why are you printing the data to the output window, this doesn't seem to have any benefit that I can see. &amp;nbsp;Secondly why are you using proc export, that gives a very basic data dump, with no nice formatting or anything else. &amp;nbsp;What is the Excel file for, if its for output then ods tagsets.excelxp would be better suited, if its for data transfer then really, don't use Excel - use a proper data transfer format. &amp;nbsp;Thirdly, why is this all in macro in the first place, I see nothing here that requires it. &amp;nbsp;Also there is no need to create a dataset just to work on, here is an example:&lt;/P&gt;
&lt;PRE&gt;%macro Print (var=);
  data _null_;
    set sashelp.vtable (where=(libname="SASHELP" and memname="CLASS"));
    by memname;
    call execute(cats('title "My Lending - ',memname,'";
                       proc export data=sashelp.class (where=(sex="&amp;amp;VAR."))
                                    outfile="s:\temp\rob\',memname,'.xlsx" dbms=xlsx replace;
                       run;'));
  run;
%mend Print;

%Print (var=M);&lt;/PRE&gt;
&lt;P&gt;As a final note, please look at code formatting, it is far more important than what your code does that other people can easily read and maintain it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2016 08:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289458#M59785</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-04T08:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289677#M59838</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser﻿&lt;/a&gt;: Thank you so much for your brilliant suggestion. I have tested the code, this is working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;infile&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;cards&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;missover&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;length&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; first last $&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;20&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; first $ last $ ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;jone smith&lt;/P&gt;&lt;P&gt;john wayne&lt;/P&gt;&lt;P&gt;bill&lt;/P&gt;&lt;P&gt;phil hodge&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; test2;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; test;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;name = catx(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;", "&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;, of last first );&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;name1 = cat(of last first);&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;name2 = cats(of last first); &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/*leading and trailing blanks*/&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;name3 = catt(of last first); &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/*trailing blanks*/&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; test3;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; test;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; first = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'john'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;print&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; = test3;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; first= john;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; execute(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"data test3; set test; where first ='&amp;amp;first'; Proc print data = test3; run; "&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; first=john;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; execute(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'data test4; set test; where first="&amp;amp;first"; proc print data = test4; run; '&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Apply this principle, I have modified my code. I still got error message. Probably there is something wrong with Proc export function.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;CODE class=" language-sas"&gt;%macro print_report(CR_APPL_NO);
proc sql nonprint;
create table table_list as
select distinct memname
from sashelp.vtable
where libname ='ELTML' 
and upper(memname) like 'MLT%';
quit;

%*use Call execute to print each table for specified record;
%*I create the strings as an extra step to allow for debugging;
%*You should remove the PUT statements after you have this working;
data _null_;
/*data commands;*/

SET TABLE_LIST;

str1=cats( "Title 'Mylending Tables-", upcase(memname), "';");
str2=cat("Proc Print Data=ELTML.", memname, "NOOBS;", "Where CR_APPL_NO=&amp;amp;CR_APPL_NO; RUN;");
str3=cat("Proc export data=ELTML.", memname, " (Where CR_APPL_NO=&amp;amp;CR_APPL_NO) 
dbms=xlsx  outfile='&amp;amp;\\WLGFILE2\&amp;lt;PATH&amp;gt;\&amp;amp;CR_APPL_NO&amp;amp;'
replace; RUN;");


call execute(str1);
call execute(str2);
call execute(str3);


%mend;

%print_report(60048444);&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Can anyone spot what is wrong with my str3 code?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2016 22:20:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289677#M59838</guid>
      <dc:creator>Nancy05</dc:creator>
      <dc:date>2016-08-04T22:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289679#M59839</link>
      <description>&lt;P&gt;Sorry, post the code in wrong format. do it again.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro print_report(CR_APPL_NO);
proc sql nonprint;
create table table_list as
select distinct memname
from sashelp.vtable
where libname ='ELTML' 
and upper(memname) like 'MLT%';
quit;

%*use Call execute to print each table for specified record;
%*I create the strings as an extra step to allow for debugging;
%*You should remove the PUT statements after you have this working;
data _null_;
/*data commands;*/

SET TABLE_LIST;

str1=cats( "Title 'Mylending Tables-", upcase(memname), "';");
str2=cat("Proc Print Data=ELTML.", memname, "NOOBS;", "Where CR_APPL_NO=&amp;amp;CR_APPL_NO; RUN;");
str3=cat("Proc export data=ELTML.", memname, " (Where CR_APPL_NO=&amp;amp;CR_APPL_NO) 
dbms=xlsx  outfile='&amp;amp;\\WLGFILE2\&amp;lt;PATH&amp;gt;\&amp;amp;CR_APPL_NO&amp;amp;'
replace; RUN;");


call execute(str1);
call execute(str2);
call execute(str3);


%mend;

%print_report(60048444);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Aug 2016 22:24:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289679#M59839</guid>
      <dc:creator>Nancy05</dc:creator>
      <dc:date>2016-08-04T22:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289703#M59845</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt;&amp;nbsp;: Thank you so much for your suggestion and code. &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;I took a while to understand your code. I have tried out your code and working well with one dataset. (eg. SASHLP.CLASS)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;try to&amp;nbsp;apply your code to my situation. This is best I could think of. The problem is that I am not quite sure how to determin memname as menname like 'MTL%'...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code still got error, but I am sure how to determin memname...as my memname is not a dataset, but many (more than 90 dataset actually) and all started with 'MLT".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Print (var=);
  data _null_;
   set sashelp.vtable (where=(libname="ELTML" and  upper(memname) like 'MLT%'));
   by memname;
   call execute(cats('title "My Lending - ',memname,'";
                       proc export data=sashelp.vtable (where=(libname="ELTML" and  upper(memname) like 'MLT%'))
					    outfile="\\WLGFILE2\&amp;lt;Path&amp;gt;\',memname,'.xlsx" 
						dbms=xlsx 
						replace;
                       run;'));
  run;
%mend Print;

%Print (var=60048444);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any more suggestions would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 03:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289703#M59845</guid>
      <dc:creator>Nancy05</dc:creator>
      <dc:date>2016-08-05T03:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289710#M59847</link>
      <description>&lt;P&gt;You really need to pay attention to your quotes Nancy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Edit:&amp;nbsp;I fixed the syntax, but the logic is odd. &amp;nbsp;No time to look now though. Later if no one replied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Print (var=);
  data _null_;
   set sashelp.vtable (where=(libname="ELTML" and  upper(memname) like 'MLT%'));
   by memname;
   call execute(cats('title "My Lending - ',memname,'";
    proc export data=sashelp.vtable (where=(libname="ELTML" and  upper(memname) like "MLT%"))
    outfile="\\WLGFILE2\&amp;lt;Path&amp;gt;\',memname,'.xlsx" 
    dbms=xlsx 
    replace;
    run;'));
  run;
%mend Print;

%Print (var=60048444);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 05:06:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289710#M59847</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-08-05T05:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289714#M59850</link>
      <description>&lt;P&gt;Note that your code doesn't use the macro variable VAR anywhere, so your datasets that are exported are the full datasets, not the subset on the variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure why you're not including in the original macro above and trying a new one either. &amp;nbsp;Its the same methodology as above, just subset for only the export.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 05:26:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289714#M59850</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-05T05:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289716#M59851</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/91404"&gt;@Nancy05&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Sorry, post the code in wrong format. do it again.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro print_report(CR_APPL_NO);
proc sql nonprint;
create table table_list as
select distinct memname
from sashelp.vtable
where libname ='ELTML' 
and upper(memname) like 'MLT%';
quit;

%*use Call execute to print each table for specified record;
%*I create the strings as an extra step to allow for debugging;
%*You should remove the PUT statements after you have this working;
data _null_;
/*data commands;*/

SET TABLE_LIST;

str1=cats( "Title 'Mylending Tables-", upcase(memname), "';");
str2=cat("Proc Print Data=ELTML.", memname, "NOOBS;", "Where CR_APPL_NO=&amp;amp;CR_APPL_NO; RUN;");
str3=cat("Proc export data=ELTML.", memname, " (Where CR_APPL_NO=&amp;amp;CR_APPL_NO) 
dbms=xlsx  outfile='&amp;amp;\\WLGFILE2\&amp;lt;PATH&amp;gt;\&amp;amp;CR_APPL_NO&amp;amp;'
replace; RUN;");


call execute(str1);
call execute(str2);
call execute(str3);


%mend;

%print_report(60048444);&lt;/CODE&gt;&lt;/PRE&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;What does str3 resolve to in the dataset? You should get code that you can take and paste into a program editor and run. If it doesn't it will at least let you know the issue you need to fix.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put str3;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;befoe you Call Execute to see the full value in the log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OR change the data _null_ to data check, and examine your dataset.&amp;nbsp;&lt;/P&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 05:32:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289716#M59851</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-05T05:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289725#M59854</link>
      <description>&lt;P&gt;I think you mean:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Print (var=);
  data _null_;
   set SASHELP.VTABLE (where=(LIBNAME="ELTML" and upper(MEMNAME) like 'MLT%'));
   call execute(cats('title "My Lending - ',MEMNAME,'";
            proc export data=ELTML.',MEMNAME,"(where CR_APPL_NO=&amp;amp;var)",'
            outfile="\\WLGFILE2\&amp;lt;Path&amp;gt;\',MEMNAME,'.xlsx" 
            dbms=xlsx 
            replace;
            run;'));
  run;
%mend Print;

%Print (var=60048444);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 06:33:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289725#M59854</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-08-05T06:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289726#M59855</link>
      <description>&lt;P&gt;The first thing that catches my eye is the nonprint option on the proc sql. This should be noprint.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 06:31:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/289726#M59855</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-05T06:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/290047#M59954</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;: Thanks for the new code. I feel I am so close to the answer but just could not get it working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code can produce table_list; But no matter how I modify the code, I still get error message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;                     180
ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even I use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put str3;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I couldn't see how it help me debugging...I also got this warning message:&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;74         %print_report(60048444);
NOTE: Compressing data set WORK.TABLE_LIST increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: Table WORK.TABLE_LIST created, with 100 rows and 1 columns.

NOTE: PROCEDURE SQL used (Total process time):
      real time           0.11 seconds
      user cpu time       0.01 seconds
      system cpu time     0.09 seconds
      memory              5204.03k
      OS Memory           30304.00k
      Timestamp           08/08/2016 09:50:23 AM
      Step Count                        233  Switch Count  24&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But I know this piece of code working (Just for helping debugging purpose!) It does not need '&amp;amp;' in front of "\\"&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;data test;
   infile cards missover;
   length first last $20;
   input first $ last $  ;
datalines;
jone smith
john wayne
bill 
phil hodge
;
run;

%let first=john;
data _null_;
call execute("proc export data=test (where=(first='&amp;amp;first')) 
		outfile='\\WLGFILE2\&amp;lt;PATH&amp;gt;\test2.xlsx' 
		dbms=xlsx 
		replace; 
		RUN;");
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This made me wonder whether SAS can handle with dynamic subset?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Aug 2016 22:05:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/290047#M59954</guid>
      <dc:creator>Nancy05</dc:creator>
      <dc:date>2016-08-07T22:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/290048#M59955</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser﻿&lt;/a&gt;&amp;nbsp;: Thanks for your comment. I have changed "nonprint" to "noprint" in proc sql.&amp;nbsp; Actually, I don't know the difference, From SAS site, some example use 'noprint", some use 'nonprint'.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Aug 2016 22:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/290048#M59955</guid>
      <dc:creator>Nancy05</dc:creator>
      <dc:date>2016-08-07T22:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/290050#M59956</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ﻿&lt;/a&gt;: Thank you so much for your code! The good news is the code is working without any syntax error&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the problem is: It produce nearly 100 spreadsheets ( 1 sheet per databset/table), but its contents exactlly the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: The query as specified involves ordering by an item that doesn't appear in its SELECT clause.
NOTE: The export data set has 100 observations and 41 variables.
NOTE: "\\WLGFILE2\BNZT Groups\&amp;lt;PATH&amp;gt;\MLT_SECURED_PROD.xlsx" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
      real time           2.46 seconds
      user cpu time       0.49 seconds
      system cpu time     1.27 seconds
      memory              7950.21k
      OS Memory           183580.00k
      Timestamp           08/08/2016 10:59:50 AM
      Step Count                        626  Switch Count  28
      &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It doesn't help even I change one line code as below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	outfile="\\WLGFILE2\&amp;lt;PATH&amp;gt;\', &amp;amp;var.,'.xlsx" &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Do you have any further suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 07 Aug 2016 23:11:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/290050#M59956</guid>
      <dc:creator>Nancy05</dc:creator>
      <dc:date>2016-08-07T23:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/290057#M59959</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/91404"&gt;@Nancy05﻿&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post what you get from the put statement. It should be valid SAS code that you can copy and run. If it isn't then you have a mistake in your code, which you obviously do. It's most likely a semicolon error. And if you run the pasted copy SAS highlights the line that's the issue. As is, we're trying to guess. That's a waste of everyone's time. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is also why you should understand what your trying to do. So far I think your still using code that you don't understand which is dangerous and risky. Especially if you end up in a time crunch since you won't be able to modify it if needed. And it's unlikely you'll be able to reuse it either.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 00:03:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/290057#M59959</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-08T00:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/290060#M59960</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;: Thank you so much for your reply.&lt;/P&gt;&lt;P&gt;I confess that I don't fully understand the meaning of put function. How to get the valid SAS code from put statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I can find about put function. But it doesn't tell me how to get value from get statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#n0mlfb88dkhbmun1x08qbh5xbs7e.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#n0mlfb88dkhbmun1x08qbh5xbs7e.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think that I understand cat function and proc export in static.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again!&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 01:54:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/290060#M59960</guid>
      <dc:creator>Nancy05</dc:creator>
      <dc:date>2016-08-08T01:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dynamic datasets to file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/290062#M59961</link>
      <description>&lt;P&gt;Read your log? You should always read your log...&lt;/P&gt;
&lt;P&gt;PUT prints the content of the variable or string to the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Functions use parentheses. This is the PUT statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#n1spe7nmkmi7ywn175002rof97fv.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#n1spe7nmkmi7ywn175002rof97fv.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;H1 class="xis-title"&gt;&lt;FONT size="3"&gt;PUT Statement&lt;/FONT&gt;&lt;/H1&gt;
&lt;P class="xis-shortDescription"&gt;Writes lines to the SAS log, to the SAS output window, or to an external location that is specified in the most recent FILE statement.&lt;/P&gt; &lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 08 Aug 2016 02:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dynamic-datasets-to-file/m-p/290062#M59961</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-08T02:24:44Z</dc:date>
    </item>
  </channel>
</rss>

