<?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 for 'combinations' in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-for-combinations/m-p/344231#M79091</link>
    <description>hmmm....nope. I have thousands of patients and 99 codes and 2 sexes.&lt;BR /&gt;so for every combination of sex and code, I want to print the pt IDs&lt;BR /&gt;for example I want to know the IDs of all the patients who are M and are in&lt;BR /&gt;for a 64 ( which is psychiatric services), and so on and so forth. A macro&lt;BR /&gt;could do this..&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
    <pubDate>Sat, 25 Mar 2017 01:03:15 GMT</pubDate>
    <dc:creator>K_S</dc:creator>
    <dc:date>2017-03-25T01:03:15Z</dc:date>
    <item>
      <title>macro for 'combinations'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-for-combinations/m-p/344228#M79089</link>
      <description>&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;pt ID&lt;/TD&gt;&lt;TD&gt;sex&lt;/TD&gt;&lt;TD&gt;service ID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;M&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;34&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;77&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;M&lt;/TD&gt;&lt;TD&gt;47&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;M&lt;/TD&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;845&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2384&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;99&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4905&lt;/TD&gt;&lt;TD&gt;M&lt;/TD&gt;&lt;TD&gt;96&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;95&lt;/TD&gt;&lt;TD&gt;M&lt;/TD&gt;&lt;TD&gt;52&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;Could somebody help me create a macro that prints pt ID for any combination of sex and service ID? Service ID s go from 1 to 99.&lt;/P&gt;&lt;P&gt;I have an idea of how to do this but I wanna see if there is a better, more logical way.&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Mar 2017 00:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-for-combinations/m-p/344228#M79089</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2017-03-25T00:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: macro for 'combinations'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-for-combinations/m-p/344230#M79090</link>
      <description>&lt;P&gt;Not sure what you want. Do you want 99 records for every pt_id?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Mar 2017 00:55:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-for-combinations/m-p/344230#M79090</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-25T00:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: macro for 'combinations'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-for-combinations/m-p/344231#M79091</link>
      <description>hmmm....nope. I have thousands of patients and 99 codes and 2 sexes.&lt;BR /&gt;so for every combination of sex and code, I want to print the pt IDs&lt;BR /&gt;for example I want to know the IDs of all the patients who are M and are in&lt;BR /&gt;for a 64 ( which is psychiatric services), and so on and so forth. A macro&lt;BR /&gt;could do this..&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Sat, 25 Mar 2017 01:03:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-for-combinations/m-p/344231#M79091</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2017-03-25T01:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: macro for 'combinations'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-for-combinations/m-p/344232#M79092</link>
      <description>&lt;P&gt;If I correctly understand, you may only need something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sort data=have;
  by service_id sex ;
run;

proc print data=have;
  var pt_id;
  by service_id sex ;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Mar 2017 01:10:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-for-combinations/m-p/344232#M79092</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-25T01:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: macro for 'combinations'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-for-combinations/m-p/344235#M79093</link>
      <description>hmm...no, not what I am looking for. It has to be a macro that would allow&lt;BR /&gt;me to randomly pick combinations of sex and service IDs.&lt;BR /&gt;Let's say today I want to get the IDs of all the males who are in for a 64,&lt;BR /&gt;but then tomorrow I want to look at women who are in for a 52.&lt;BR /&gt;I am sorry if I am not making a lot of sense. I am new to this and not&lt;BR /&gt;entirely sure what I am being asked to do. All I know is that it has to be&lt;BR /&gt;a macro that would allow me to get pt_IDs for any combinations of sex and&lt;BR /&gt;service id.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Sat, 25 Mar 2017 01:26:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-for-combinations/m-p/344235#M79093</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2017-03-25T01:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: macro for 'combinations'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-for-combinations/m-p/344245#M79096</link>
      <description>&lt;P&gt;You don't need a macro, but here is one way to do it without a macro and one way using a macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc print data=have (where=(sex eq 'M' and service_id eq 22));
  var pt_id;
  by service_id sex ;
run;

/*or*/

%macro doit(sex,service_id);
  title "Patients with Gender = &amp;amp;sex. and Service_ID = &amp;amp;Service_ID";
  proc print data=have (where=(sex eq "&amp;amp;sex" and service_id eq &amp;amp;service_id));
    var pt_id;
  run;
%mend doit;

%doit(M,22)
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Mar 2017 02:23:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-for-combinations/m-p/344245#M79096</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-25T02:23:15Z</dc:date>
    </item>
    <item>
      <title>Re: macro for 'combinations'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-for-combinations/m-p/344247#M79097</link>
      <description>This is beautiful! Thank you!&lt;BR /&gt;You just helped me understand something I completely missed. Much&lt;BR /&gt;appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Sat, 25 Mar 2017 02:30:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-for-combinations/m-p/344247#M79097</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2017-03-25T02:30:15Z</dc:date>
    </item>
  </channel>
</rss>

