<?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: %Macro help for Proc Append in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Macro-help-for-Proc-Append/m-p/178011#M45490</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sorry, isn't the &lt;STRONG style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;%macro union(dsn1=workinghourscd, dsn2=workinghoursjv, out= workinghourscd_jv_combined); &lt;/STRONG&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;the macro call?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will update the errors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Feb 2014 15:33:20 GMT</pubDate>
    <dc:creator>SAS_ter</dc:creator>
    <dc:date>2014-02-18T15:33:20Z</dc:date>
    <item>
      <title>%Macro help for Proc Append</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-help-for-Proc-Append/m-p/178009#M45488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to use the following macro to append two data&lt;SPAN style="color: #333333; font-family: Arial, Helvetica, Verdana, sans-serif;"&gt;sets that have the same variable names, but some of the character variables have different lengths in the two data sets:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;49&amp;nbsp;&amp;nbsp; %macro union(dsn1=,whcd dsn2=,whjv out=&lt;/P&gt;&lt;P&gt;49 ! workinghourscd_jv_combined);&lt;/P&gt;&lt;P&gt;ERROR: Expecting comma (to separate macro parameters) or close&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parenthesis (to end parameter list) but found: dsn2&lt;/P&gt;&lt;P&gt;ERROR: A dummy macro will be compiled.&lt;/P&gt;&lt;P&gt;50&lt;/P&gt;&lt;P&gt;51&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc contents data=&amp;amp;dsn1 noprint&lt;/P&gt;&lt;P&gt;52&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out=out1;&lt;/P&gt;&lt;P&gt;53&lt;/P&gt;&lt;P&gt;54&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc contents data=&amp;amp;dsn2 noprint&lt;/P&gt;&lt;P&gt;55&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out=out2;&lt;/P&gt;&lt;P&gt;56&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;57&lt;/P&gt;&lt;P&gt;58&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;59&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; file "workinghourscd_jv_combined.sas";&lt;/P&gt;&lt;P&gt;60&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; merge out1 out2 end=last;&lt;/P&gt;&lt;P&gt;61&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by ID;&lt;/P&gt;&lt;P&gt;62&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _n_ = 1 then put "Data &amp;amp;out;";&lt;/P&gt;&lt;P&gt;63&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; l = max(length,length2);&lt;/P&gt;&lt;P&gt;64&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if last then do;&lt;/P&gt;&lt;P&gt;65&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put "&amp;nbsp;&amp;nbsp; set &amp;amp;dsn1 &amp;amp;dsn2;";&lt;/P&gt;&lt;P&gt;66&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put "run;";&lt;/P&gt;&lt;P&gt;67&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;68&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;69&lt;/P&gt;&lt;P&gt;70&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %include "workinghourscd_jv_combined.sas";&lt;/P&gt;&lt;P&gt;71&lt;/P&gt;&lt;P&gt;72&amp;nbsp;&amp;nbsp; %mend union;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;N.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 14:56:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-help-for-Proc-Append/m-p/178009#M45488</guid>
      <dc:creator>SAS_ter</dc:creator>
      <dc:date>2014-02-18T14:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: %Macro help for Proc Append</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-help-for-Proc-Append/m-p/178010#M45489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't see the macro call, so perhaps is that why it isn't executed...?&lt;/P&gt;&lt;P&gt;Impossible to help if you don't share the log with the errors. It seems you have more than one problem?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 15:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-help-for-Proc-Append/m-p/178010#M45489</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-02-18T15:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: %Macro help for Proc Append</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-help-for-Proc-Append/m-p/178011#M45490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sorry, isn't the &lt;STRONG style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;%macro union(dsn1=workinghourscd, dsn2=workinghoursjv, out= workinghourscd_jv_combined); &lt;/STRONG&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;the macro call?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will update the errors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 15:33:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-help-for-Proc-Append/m-p/178011#M45490</guid>
      <dc:creator>SAS_ter</dc:creator>
      <dc:date>2014-02-18T15:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: %Macro help for Proc Append</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-help-for-Proc-Append/m-p/178012#M45491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;SAS'ter wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;sorry, isn't the &lt;STRONG style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;%macro union(dsn1=workinghourscd, dsn2=workinghoursjv, out= workinghourscd_jv_combined); &lt;/STRONG&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;the macro call?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;No, that is the start of definition. To excute a macro you would have something like&lt;/P&gt;&lt;P&gt;%union(dsn1=workinghourscd, dsn2=workinghoursjv, out= workinghourscd_jv_combined);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You're going to need a lot more work if your goal is to remove the warning about mismatched lengths. If all of the longer variables are in one dataset the quick and dirty approach would be to place that dataset name first on the SET statement and ignore the warning. Otherwise you will want to create a Length statement that appears beforethe Set statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 15:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-help-for-Proc-Append/m-p/178012#M45491</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-02-18T15:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: %Macro help for Proc Append</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-help-for-Proc-Append/m-p/178013#M45492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I will remove the "macro" bit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My goal is to automate it, so that SAS looks at the two data sets and chooses the longest length of the same variables to append. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 16:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-help-for-Proc-Append/m-p/178013#M45492</guid>
      <dc:creator>SAS_ter</dc:creator>
      <dc:date>2014-02-18T16:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: %Macro help for Proc Append</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-help-for-Proc-Append/m-p/178014#M45493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something like this will put the character variables into a list suitable for use in a length statement in a data step&lt;/P&gt;&lt;P&gt;The DSN1 and 2 must resolve to be in upper case, if they are in separate libraries than you need to modify the parameters to include both libraries, (lib1=, lib2= for example), make similar %upcase assignment, in the comparison (libname in ("&amp;amp;lib1","&amp;amp;lib2")) and the set statement, set &amp;amp;lib1..&amp;amp;dsn1 &amp;amp;lib2..&amp;amp;dsn2 ;&lt;/P&gt;&lt;P&gt;Note the value for the comparison TYPE='char' , char must be lower case as that is how this is stored in the dictionary table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro stack (lib=, dsn1=, dsn2=, outset=);&lt;/P&gt;&lt;P&gt;%let lib=%upcase(&amp;amp;lib);&lt;/P&gt;&lt;P&gt;%let dsn1=%upcase(&amp;amp;dsn1);&lt;/P&gt;&lt;P&gt;%let dsn2=%upcase(&amp;amp;dsn2);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;/*&amp;nbsp;&amp;nbsp; create table varlengths as*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select string into :varlengths separated by ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select catx(' $ ',name,MAX(length)) as string &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from dictionary.columns &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where libname="&amp;amp;LIB" and memname in ("&amp;amp;DSN1","&amp;amp;DSN2")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND TYPE='char' &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; group by name)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data &amp;amp;outset;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; length &amp;amp;varlengths ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &amp;amp;lib..&amp;amp;dsn1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;lib..&amp;amp;dsn2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;and to execute somethingl like:&lt;/P&gt;&lt;P&gt;%stack (lib=work, dsn1=set1, dsn2=set2, outset=combinedset);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 18:36:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-help-for-Proc-Append/m-p/178014#M45493</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-02-18T18:36:25Z</dc:date>
    </item>
  </channel>
</rss>

