<?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: Appending dataset in Macro loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547932#M151891</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/268247"&gt;@dwights&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	SignificantColumn="&amp;amp;variable";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I put in the quotes, I get this error -&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WARNING: Variable SignificantColumn not appended because of type mismatch.&lt;BR /&gt;WARNING: Variable CLSTR_NM was not found on DATA file.&lt;BR /&gt;ERROR: No appending done because of anomalies listed above. Use FORCE option to append these files.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which tells that SignificantColumn in the BASE data set is numeric. Run proc contents on the data set to verify variable types and lengths.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Apr 2019 15:37:43 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-04-02T15:37:43Z</dc:date>
    <item>
      <title>Appending dataset in Macro loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547738#M151819</link>
      <description>&lt;P&gt;I'm trying to create a table of all macro variables which follow a particular condition.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=1 to &amp;amp;N;

%let variable = %scan(&amp;amp;varlist,&amp;amp;i); 



*/

*&amp;nbsp; Code

*/

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%if(condition) %then %do;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;data tempSignificance;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SignificantColumn="&amp;amp;variable";
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;run;



&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; proc append base=FinalSignificance data=tempSignificance ;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; run;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %end;



proc sql;
drop table tempSignificance;
quit;

 %end;&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;The above code is creating the following table -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;SignificantColumn&lt;/TD&gt;&lt;TD&gt;CLSTR_NM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I want the table in the following format -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;SignificantColumn&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CLSTR_NM&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please let me know. TIA&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 20:57:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547738#M151819</guid>
      <dc:creator>dwights</dc:creator>
      <dc:date>2019-04-01T20:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: Appending dataset in Macro loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547739#M151820</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above code is creating the following table -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;SignificantColumn&lt;/TD&gt;
&lt;TD&gt;CLSTR_NM&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect that you may have created your FinalSignificance data set in a manner that has the variable SignificantColumn as numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you are starting in the middle and missing lots of parts such as&lt;/P&gt;
&lt;P&gt;1) the complete text of macro code&lt;/P&gt;
&lt;P&gt;2) the actual value of your &amp;amp;varlist macro variable,&lt;/P&gt;
&lt;P&gt;3) your macro loop is missing the % for %to so I suspect your macro may have actually failed to compile and has not replaced an earlier version of a set&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question:&lt;/P&gt;
&lt;P&gt;Did you have code that did this successfully without any macro bits? If so, look at it closely. If not, create. Add one piece at a time.&lt;/P&gt;
&lt;P&gt;Another issue you may have is the length of the variable SignificantColumn. If the initial value is less than later values you are either going to get failure of appends due to different lengths or truncation of data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also save a lot of unneeded temporary data set with something like:&lt;/P&gt;
&lt;PRE&gt;data tempSignificance;
   length  SignificantColumn $ 32;
   %do i=1 %to &amp;amp;n.;
      %let variable = %scan(&amp;amp;varlist.,&amp;amp;i.); 
      SignificantColumn="&amp;amp;variable.";
      output;
   %end;
 run;&lt;/PRE&gt;
&lt;P&gt;which should assign all of the variables into a single data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But where did you build your &amp;amp;varlist? It may be that you already had the pieces you needed and have spent additional time taking them out of a source such as Dictionary.columns just to place them back into another table. If that is the approach you used then perhaps evaluating the conditions first and selecting from Dictionary.Columns for the append would be appropriate.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 21:24:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547739#M151820</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-01T21:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Appending dataset in Macro loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547753#M151830</link>
      <description>&lt;P&gt;I agree with everything&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;said, including the importance of using a LENGTH statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The results you got are consistent with accidentally removing the quotes in this portion of the program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;
         &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; tempSignificance&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
         SignificantColumn&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"&amp;amp;variable"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
         &lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Apr 2019 22:23:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547753#M151830</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-01T22:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Appending dataset in Macro loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547795#M151848</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	SignificantColumn="&amp;amp;variable";&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I put in the quotes, I get this error -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: Variable SignificantColumn not appended because of type mismatch.&lt;BR /&gt;WARNING: Variable CLSTR_NM was not found on DATA file.&lt;BR /&gt;ERROR: No appending done because of anomalies listed above. Use FORCE option to append these files.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 03:05:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547795#M151848</guid>
      <dc:creator>dwights</dc:creator>
      <dc:date>2019-04-02T03:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: Appending dataset in Macro loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547796#M151849</link>
      <description>&lt;P&gt;The varlist contains list of all column names of a table (got the list using proc contents) . CLSTR_NM is a column of that table which satisfies the if condition(which is a t-test result being significant) . What I'm trying to do in the code is get the list of all columns which are statistically significant when compared from two tables. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 03:12:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547796#M151849</guid>
      <dc:creator>dwights</dc:creator>
      <dc:date>2019-04-02T03:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: Appending dataset in Macro loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547830#M151857</link>
      <description>&lt;P&gt;Step 1 of macro development: start with working Base SAS code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create the code that works with one instance from your varlist. Once that works without WARNINGs/ERRORs, start making it dynamic.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 08:09:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547830#M151857</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-02T08:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: Appending dataset in Macro loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547835#M151859</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Random values for the example */
data _NULL_;
    array a a1-a10;
    do over a;
        a=10*rand("Uniform");
        call symputx(vname(a),a);
    end;
run;

data FinalSignificance;
    length SignificantColumn $5.;
    call missing(SignificantColumn);
    stop;
run;


data _NULL_;
    array mv $5. a1-a10; /* List the macrovariables names here */

    call execute('proc sql;');

    do over mv;
        mv=symget(vname(mv));

        if mv&amp;gt;5 then do;
            call execute(cats('insert into FinalSignificance set SignificantColumn="',mv,'";'));
        end;
    end;

    call execute('quit;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Apr 2019 08:55:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547835#M151859</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-04-02T08:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: Appending dataset in Macro loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547932#M151891</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/268247"&gt;@dwights&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	SignificantColumn="&amp;amp;variable";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I put in the quotes, I get this error -&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WARNING: Variable SignificantColumn not appended because of type mismatch.&lt;BR /&gt;WARNING: Variable CLSTR_NM was not found on DATA file.&lt;BR /&gt;ERROR: No appending done because of anomalies listed above. Use FORCE option to append these files.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which tells that SignificantColumn in the BASE data set is numeric. Run proc contents on the data set to verify variable types and lengths.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 15:37:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547932#M151891</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-02T15:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: Appending dataset in Macro loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547934#M151892</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/268247"&gt;@dwights&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The varlist contains list of all column names of a table (got the list using proc contents) . CLSTR_NM is a column of that table which satisfies the if condition(which is a t-test result being significant) . What I'm trying to do in the code is get the list of all columns which are statistically significant when compared from two tables. Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So show the code how you actually derived that list.&lt;/P&gt;
&lt;P&gt;And possibly more important at this point since you keep getting append errors: Code for how you build the BASE dataset you are using in the Proc Append code.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 15:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/547934#M151892</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-02T15:39:36Z</dc:date>
    </item>
  </channel>
</rss>

