<?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: ods tagsets.EXCELXP whit macro var in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18783#M3664</link>
    <description>First of all move the ODS open command inside you macro.  You are opening a file once and closing it 95 times.</description>
    <pubDate>Wed, 18 Nov 2009 14:19:54 GMT</pubDate>
    <dc:creator>Flip</dc:creator>
    <dc:date>2009-11-18T14:19:54Z</dc:date>
    <item>
      <title>ods tagsets.EXCELXP whit macro var</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18782#M3663</link>
      <description>Hi there,&lt;BR /&gt;
&lt;BR /&gt;
 I would like print to Excel sheets  380 tables "sas" by using 4 "proc FREQ" &lt;BR /&gt;
&lt;BR /&gt;
&lt;U&gt;This is my program :&lt;/U&gt;&lt;BR /&gt;
&lt;BR /&gt;
ods tagsets.EXCELXP file="D:\S\&amp;amp;school.xls" ;&lt;BR /&gt;
&lt;BR /&gt;
%macro test ;&lt;BR /&gt;
%do cpt = 1 %to 95  ; &lt;BR /&gt;
%if &amp;amp;cpt =1 %then  %let  school =0372604S ;&lt;BR /&gt;
%if &amp;amp;cpt =2 %then  %let  school =0370049P ;&lt;BR /&gt;
%if &amp;amp;cpt =3 %then  %let school =0370002N ;&lt;BR /&gt;
&lt;BR /&gt;
proc freq data= a.table (where=(school="&amp;amp;school"));&lt;BR /&gt;
table school*var1*var2*var3/ missprint nocol nopercent nofreq norow noprint out= sasuser.tbx1&amp;amp;school ;&lt;BR /&gt;
format school $school. ;&lt;BR /&gt;
run;&lt;BR /&gt;
ods tagsets.Excelxp close;&lt;BR /&gt;
%end ;&lt;BR /&gt;
%mend ;&lt;BR /&gt;
%test ;&lt;BR /&gt;
&lt;BR /&gt;
Could you please find out any anomalies in this program, and if you could&lt;BR /&gt;
propose any alternatives that could fix this program. &lt;BR /&gt;
&lt;BR /&gt;
Thank for your assistance in advance.&lt;B&gt;&lt;/B&gt;&lt;B&gt;&lt;/B&gt;</description>
      <pubDate>Wed, 18 Nov 2009 13:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18782#M3663</guid>
      <dc:creator>janne2</dc:creator>
      <dc:date>2009-11-18T13:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: ods tagsets.EXCELXP whit macro var</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18783#M3664</link>
      <description>First of all move the ODS open command inside you macro.  You are opening a file once and closing it 95 times.</description>
      <pubDate>Wed, 18 Nov 2009 14:19:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18783#M3664</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2009-11-18T14:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: ods tagsets.EXCELXP whit macro var</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18784#M3665</link>
      <description>How ? I don't understand what do you mean ?</description>
      <pubDate>Wed, 18 Nov 2009 14:24:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18784#M3665</guid>
      <dc:creator>janne2</dc:creator>
      <dc:date>2009-11-18T14:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: ods tagsets.EXCELXP whit macro var</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18785#M3666</link>
      <description>Add the following SAS command to help you self-diagnose the problem -- you will see how SAS is resolving your macro variable.  More specifically, you declared the macro variable at a point where it either has not value or the value is static, and then you intend to iterate with the %DO / %END.  Review the SAS log after adding:&lt;BR /&gt;
&lt;BR /&gt;
OPTIONS SOURCE SOURCE2 MACROGEN SYMBOLGEN MLOGIC;&lt;BR /&gt;
&lt;BR /&gt;
You will see the processing in detail -- hopefully that will help.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 18 Nov 2009 14:45:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18785#M3666</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-11-18T14:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: ods tagsets.EXCELXP whit macro var</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18786#M3667</link>
      <description>You're reason, i've mooved the ods under the macro, but  the proc freq das not work because of the "&amp;amp;" (table var1*var2*var3/nopercent......out = sasuser.&lt;B&gt;&amp;amp;&lt;/B&gt;scholl);&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;log: Apparent symbolic reference school not resolved.&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
Please help me, i'am new sas user.&lt;BR /&gt;
&lt;BR /&gt;
Thank's a lot.</description>
      <pubDate>Wed, 18 Nov 2009 15:13:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18786#M3667</guid>
      <dc:creator>janne2</dc:creator>
      <dc:date>2009-11-18T15:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: ods tagsets.EXCELXP whit macro var</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18787#M3668</link>
      <description>Your code does no assign a variable value to SCHOOL in all cases, so you are getting an unresolved macro variable error.  So, your %LET logic needs to be complete for all possible CPT values -- possibly just adding a %ELSE %LET  assignment statement -- I don't know your application's needs though, so you must decide, or maybe a null value?.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 18 Nov 2009 16:35:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18787#M3668</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-11-18T16:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: ods tagsets.EXCELXP whit macro var</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18788#M3669</link>
      <description>Being a new SAS user, maybe some basics review is in order.  It's unclear how you can expect to support your own code, if you cannot understand how it is executing.  That was one reason for suggesting you expand the amount of SAS-generated diagnostics information to your log.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
SAS Macro Language: Reference, Introduction to the Macro Facility&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002293969.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002293969.htm&lt;/A&gt;</description>
      <pubDate>Wed, 18 Nov 2009 16:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18788#M3669</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-11-18T16:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: ods tagsets.EXCELXP whit macro var</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18789#M3670</link>
      <description>if the line ods tagsets.EXCELXP file="D:\S\&amp;amp;school.xls" ; is not inside the macro then &amp;amp;school has not been assigned.  Secondly the macro var school resolving within a string needs a terminator.  SAS assumes this is what the . is for so you will get no . between the name and xls.  You need to write this as &lt;BR /&gt;
ods tagsets.EXCELXP file="D:\S\&amp;amp;school..xls" ;  with .. after the &amp;amp;school.&lt;BR /&gt;
&lt;BR /&gt;
As Scott pointed out you seem to be having trouble with very basic concepts of macros, and need to get a handle on these.  If it will help you, I might write this code something like the following.&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
input school $;&lt;BR /&gt;
call symput(compress("school" || put(_n_, best.)), school);&lt;BR /&gt;
cards;&lt;BR /&gt;
0372604S&lt;BR /&gt;
0370049P&lt;BR /&gt;
0370002N&lt;BR /&gt;
;;;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%macro test ;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%do cpt = 1 %to 3 ;&lt;BR /&gt;
%put &amp;amp;&amp;amp;school&amp;amp;cpt ;&lt;BR /&gt;
&lt;BR /&gt;
ods tagsets.EXCELXP file="D:\S\&amp;amp;&amp;amp;school&amp;amp;cpt..xls" ;&lt;BR /&gt;
proc freq data= a.table (where=(school="&amp;amp;&amp;amp;school&amp;amp;cpt"));&lt;BR /&gt;
table school*var1*var2*var3/ missprint nocol nopercent nofreq norow noprint out= sasuser.tbx1&amp;amp;&amp;amp;school&amp;amp;cpt ;&lt;BR /&gt;
format school $school. ;&lt;BR /&gt;
run;&lt;BR /&gt;
ods tagsets.Excelxp close;&lt;BR /&gt;
%end ;&lt;BR /&gt;
%mend ;&lt;BR /&gt;
%test ;</description>
      <pubDate>Wed, 18 Nov 2009 18:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ods-tagsets-EXCELXP-whit-macro-var/m-p/18789#M3670</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2009-11-18T18:54:17Z</dc:date>
    </item>
  </channel>
</rss>

