<?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 Macro multiple class variables for npar1way analysis in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-class-variables-for-npar1way-analysis/m-p/895956#M353992</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me to set up macro to do 'proc npar1way' analysis. I have 20 variables in 'dicom_cat', and I would like to set up 'class' by selecting 1 variable from 'dicom_cat' each time for the analysis. So far, I've got SAS codes like these but it is not working... Please help me how I should set them up. Thank you very much!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%macro KWloop(class= );	
%let count=1;
%do %until (%scan(&amp;amp;dicom_cat, &amp;amp;count)=);
%let x=%scan(&amp;amp;dicom_cat, &amp;amp;count);
proc npar1way data=&amp;amp;dsn;
class &amp;amp;x;
var &amp;amp;feature_vars;
run;&lt;BR /&gt;
%let count=%eval(&amp;amp;count+1);
%end;
%mend KWloop;

%KWloop (class=1);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 26 Sep 2023 20:30:14 GMT</pubDate>
    <dc:creator>mango_tango_598</dc:creator>
    <dc:date>2023-09-26T20:30:14Z</dc:date>
    <item>
      <title>Macro multiple class variables for npar1way analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-class-variables-for-npar1way-analysis/m-p/895956#M353992</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me to set up macro to do 'proc npar1way' analysis. I have 20 variables in 'dicom_cat', and I would like to set up 'class' by selecting 1 variable from 'dicom_cat' each time for the analysis. So far, I've got SAS codes like these but it is not working... Please help me how I should set them up. Thank you very much!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%macro KWloop(class= );	
%let count=1;
%do %until (%scan(&amp;amp;dicom_cat, &amp;amp;count)=);
%let x=%scan(&amp;amp;dicom_cat, &amp;amp;count);
proc npar1way data=&amp;amp;dsn;
class &amp;amp;x;
var &amp;amp;feature_vars;
run;&lt;BR /&gt;
%let count=%eval(&amp;amp;count+1);
%end;
%mend KWloop;

%KWloop (class=1);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Sep 2023 20:30:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-class-variables-for-npar1way-analysis/m-p/895956#M353992</guid>
      <dc:creator>mango_tango_598</dc:creator>
      <dc:date>2023-09-26T20:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro multiple class variables for npar1way analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-class-variables-for-npar1way-analysis/m-p/895969#M353995</link>
      <description>&lt;P&gt;What is the value of &amp;amp;dicom_cat? Where is it set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Checking for "blanks" in the macro language is not trivial.&lt;/P&gt;
&lt;P&gt;IF &amp;amp;dicon_cat is a space delimited list like: thisvar thatvar anothervar&lt;/P&gt;
&lt;P&gt;then I would write something more like:&lt;/P&gt;
&lt;PRE&gt;%macro KWloop( );	
  
   %do i = 1 %to %sysfunc(countw,&amp;amp;dicom_cat.); 
      %let x=%scan(&amp;amp;dicom_cat., &amp;amp;i.);
      proc npar1way data=&amp;amp;dsn;
      class &amp;amp;x;
      var &amp;amp;feature_vars;
      run;

   %end;
%mend KWloop;&lt;/PRE&gt;
&lt;P&gt;Personally I would make Dicom_cat the parameter of the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above loops over every variable in the list, if Dicom_cat is an actual list of variables and calls the procedure once with with each variable as a Class variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is poor form to just have macro variables, such as Dicom_cat or Feature_var magically appear in the middle of code, especially&amp;nbsp; if there is no mention of where the values are set or what they should contain.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are thinking of extending this to groups of 2 or 3 or more more variables I would suggest using a data step to write the code to a text file and %include that file after verifying the code works. I suggest that approach because of the functions like allcombi that will create combinations and permulations of values. Writing to the text file to document what you run and have it is a model for the next time.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2023 22:34:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-class-variables-for-npar1way-analysis/m-p/895969#M353995</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-09-26T22:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Macro multiple class variables for npar1way analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-class-variables-for-npar1way-analysis/m-p/895979#M354000</link>
      <description>&lt;P&gt;Thank you very much for the response! I am so sorry that I did not explain well about my dataset. I figured it out much easier way without using loop.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2023 23:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-class-variables-for-npar1way-analysis/m-p/895979#M354000</guid>
      <dc:creator>mango_tango_598</dc:creator>
      <dc:date>2023-09-26T23:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: Macro multiple class variables for npar1way analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-class-variables-for-npar1way-analysis/m-p/896085#M354042</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/449370"&gt;@mango_tango_598&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you very much for the response! I am so sorry that I did not explain well about my dataset. I figured it out much easier way without using loop.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You should share your solution. That way anyone else landing here from a search for a similar question can see if your solution would work for them.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 15:28:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-class-variables-for-npar1way-analysis/m-p/896085#M354042</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-09-27T15:28:07Z</dc:date>
    </item>
  </channel>
</rss>

