<?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: How to write SAS code about this combination in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625611#M184401</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/304931"&gt;@superbug&lt;/a&gt;&amp;nbsp;in problems like this, it is always easier to solve a smaller problem, which resembles your actual problem and then scale up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suppose your data looks like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input itempos key COL1-COL3;
infile datalines dlm=',';
datalines;
1,1,3,3,1
2,3,3,3,3
3,1,1,1,1
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What do you want the result to look like?&lt;/P&gt;</description>
    <pubDate>Tue, 18 Feb 2020 14:50:52 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2020-02-18T14:50:52Z</dc:date>
    <item>
      <title>HELP PLEASE--how to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625624#M184397</link>
      <description>&lt;P&gt;A portion of my data is as in the attachment.&amp;nbsp; In the attachment, there are three items, "key" is item key, COL1 to COL3 are the responses of three candidates to those three items. I want to choose any pair from three candidates, then compare the responses of each pair with the "key".&amp;nbsp; COL12, COL13, COL23 are the results I wanted. Following are the simple SAS code to create COL12 variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;if COL1=COL2=key then COL12="same resp and both correct";&lt;/P&gt;&lt;P&gt;else if COL1=COL2 and COL1^=key then COL12="same resp and both wrong";&lt;BR /&gt;else if COL1=COL2 and COL2^=key then COL12="same resp and both wrong";&lt;/P&gt;&lt;P&gt;else if COL1=key then COL12="different resp and one of them correct";&lt;BR /&gt;else if COL2=key then COL12="different resp and one of them correct";&lt;/P&gt;&lt;P&gt;else COL12="different resp and both wrong";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because I have many 52 columns, so the&amp;nbsp; combinations of each pair would be&amp;nbsp; C(52,2)=52!.(52-2)!2!=1326. Any quick way to help me get what I wanted?&lt;/P&gt;&lt;P&gt;PLEASE HELP!&lt;/P&gt;&lt;P&gt;&amp;nbsp;thank you!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 16:01:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625624#M184397</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-02-18T16:01:07Z</dc:date>
    </item>
    <item>
      <title>How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625610#M184400</link>
      <description>&lt;P&gt;As data in the attachment. I have 250 items , "key" is the key of each item, COL1 to COL52 are the responses of 52 candidates to those 250 items. I want to choose any pair from those 52 candidates, that is, C(52, 2)=52!/(52-2)!2!, and compare the responses of EACH PAIR with the "key" . For example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data comb1;&lt;/P&gt;&lt;P&gt;set comb;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if COL1=COL2=key then category="same resp and both correct";&lt;/P&gt;&lt;P&gt;else if COL1=COL2 and COL1^=key then category="same resp and both wrong";&lt;BR /&gt;else if COL1=COL2 and COL2^=key then category="same resp and both wrong";&lt;/P&gt;&lt;P&gt;else if COL1=key then category="different resp and one of them correct";&lt;BR /&gt;else if COL2=key then category="different resp and one of them correct";&lt;/P&gt;&lt;P&gt;else category="different resp and both wrong";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because&amp;nbsp;C(52, 2)=52! / (52-2)!2! = 1326 pairs, for each pair, I want to use the code above, how should I do it in SAS?&lt;/P&gt;&lt;P&gt;thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 14:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625610#M184400</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-02-18T14:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625611#M184401</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/304931"&gt;@superbug&lt;/a&gt;&amp;nbsp;in problems like this, it is always easier to solve a smaller problem, which resembles your actual problem and then scale up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suppose your data looks like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input itempos key COL1-COL3;
infile datalines dlm=',';
datalines;
1,1,3,3,1
2,3,3,3,3
3,1,1,1,1
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What do you want the result to look like?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 14:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625611#M184401</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-02-18T14:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625615#M184402</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;use the small data you suggested, I'd like the result to be as in the attachment (have.csv). thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 15:06:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625615#M184402</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-02-18T15:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625616#M184403</link>
      <description>&lt;P&gt;Why do you want to do this? As you point out yourself, this will require 52 choose 2 =&amp;nbsp;&lt;SPAN&gt;1326 = &lt;EM&gt;too many&lt;/EM&gt; new variables in your original problem.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It can be done fairly simple, but it is not advisable. It seems&amp;nbsp;like a part of a bigger problem so what do you want to do with the new variables?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 15:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625616#M184403</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-02-18T15:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625618#M184404</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;under each pair, there are different categories on the responses compared with the key.&amp;nbsp; I want to get the freq of the categories in each pair.&lt;/P&gt;&lt;P&gt;you said "&lt;SPAN&gt;It can be done fairly simple, but it is not advisable", could you please let me know your simple way?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 15:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625618#M184404</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-02-18T15:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625622#M184405</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/304931"&gt;@superbug&lt;/a&gt;&amp;nbsp; See if this helps,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input itempos key COL1-COL3;
infile datalines dlm=',';
datalines;
1,1,3,3,1
2,3,3,3,3
3,1,1,1,1
;


data want;
 set have;
 array c col:;
 length category $30 Pair $20;
 do _i=1 to dim(c)-1;
  do _j=_i+1 to dim(c);
   k1=c(_i);
   k2=c(_j);
   Pair=catx('_','Pair',_i,_j);
   if k1=k2=key then category="same resp and both wrong";
   else if k1=k2^=key then category="same resp and both wrong";
   else if k1=key or k2=key then category="different resp and one of them correct";
   output;
  end;
 end;
 keep itempos key category pair;
run;
proc transpose data=want out=final_want(drop=_:);
by itempos key notsorted;
var category;
id pair;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Feel free to let us know if you need any clarifications. All the best!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 17:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625622#M184405</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-18T17:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: HELP PLEASE--how to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625625#M184398</link>
      <description>&lt;P&gt;oops, here is the file.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 16:01:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625625#M184398</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-02-18T16:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: HELP PLEASE--how to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625626#M184399</link>
      <description>&lt;P&gt;Seems like you reposted a duplicate of&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-write-SAS-code-about-this-combination/m-p/625610" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-write-SAS-code-about-this-combination/m-p/625610&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My apologies if my solution didn't work for you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 16:03:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625626#M184399</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-18T16:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625630#M184406</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;your solution worked!&lt;/P&gt;&lt;P&gt;Thank you so much! give you a big thumb up!!&lt;/P&gt;&lt;P&gt;Because I was so eager to get correct solutions in my previous post, while I was waiting for help, I reposted it before I get your correct solution.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 16:25:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625630#M184406</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-02-18T16:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625633#M184407</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/304931"&gt;@superbug&lt;/a&gt;&amp;nbsp; No worries, No matter what, there is never a need to duplicate for the simple reason 1. often confuses which one to respond to 2. Ethically doesn't go well 3. Yes I fully understand, sometimes the requirement is urgent and can get us panicky, however still better to stick to one and wait.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Trust me, there are about &lt;STRONG&gt;30+&lt;/STRONG&gt; of us who will respond and will attempt to offer the much needed solution. Particularly on gaming alike these kinda questions we treat this as fun. For a rather advisory role, I don't but&amp;nbsp; on the other hand I seek and take advice from senior people like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp; (Thanking Reeza for merging the thread).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So either way, you have it all. Just be patient for one of the &lt;EM&gt;&lt;STRONG&gt;30+ mentioned&lt;/STRONG&gt;&lt;/EM&gt; to respond, and on top of that a new person outside of the expected 30+ has surprised many a times.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best! Take care and have fun!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 16:36:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625633#M184407</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-18T16:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625638#M184408</link>
      <description>&lt;P&gt;Sure&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   length vars $ 20000;
   do i=1 to 52-1;
      do j=i+1 to 52;
         vars = catx(' ', vars, cats('pair_', i, '_', j));
      end;
   end;
   call symputx('vars', vars);
run;

data want(keep=itempos key pair:);
   set have;
   array c {*} col:;
   array p {1326} $ 50 &amp;amp;vars.;
   do i=1 to 52-1;
      do j=i+1 to 52;
         idx=sum(idx, 1);
         if       c[i]=c[j]=key    then p[idx] = "same resp and both wrong";
         else if  c[i]=c[j] ne key then p[idx] = "same resp and both wrong";
         else if  i=key | j=key    then p[idx] = "different resp and one of them correct";
         else                           p[idx] = "different resp and both wrong";
      end;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Feb 2020 18:34:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625638#M184408</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-02-18T18:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625644#M184412</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it worked!&lt;/P&gt;
&lt;P&gt;Thanks much for your reply!&lt;/P&gt;
&lt;P&gt;I very much appreciate your time and help!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 18:09:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625644#M184412</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-02-18T18:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625653#M184418</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You SAS expert / masters are so amazing! I feel so fortunate to join the SAS support community recently.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A follow up problem need your help.&lt;/P&gt;
&lt;P&gt;After I get&amp;nbsp; those1326 pairs, I use the following to get freq on the category of each pair&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=final_want;&lt;BR /&gt;table Pair_:/out=freq;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I got the freq tables in the "Results Viewer". For example, "pair_1_2" looks like following&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Freq: One-Way Frequencies" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l b header" scope="col"&gt;Pair_1_2&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Frequency&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Percent&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Cumulative&lt;BR /&gt;Frequency&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Cumulative&lt;BR /&gt;Percent&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;different resp and both wrong&lt;/TH&gt;
&lt;TD class="r data"&gt;35&lt;/TD&gt;
&lt;TD class="r data"&gt;17.50&lt;/TD&gt;
&lt;TD class="r data"&gt;35&lt;/TD&gt;
&lt;TD class="r data"&gt;17.50&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;different resp and one of them&lt;/TH&gt;
&lt;TD class="r data"&gt;37&lt;/TD&gt;
&lt;TD class="r data"&gt;18.50&lt;/TD&gt;
&lt;TD class="r data"&gt;72&lt;/TD&gt;
&lt;TD class="r data"&gt;36.00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;same resp and both correct&lt;/TH&gt;
&lt;TD class="r data"&gt;118&lt;/TD&gt;
&lt;TD class="r data"&gt;59.00&lt;/TD&gt;
&lt;TD class="r data"&gt;190&lt;/TD&gt;
&lt;TD class="r data"&gt;95.00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;same resp and both wrong&lt;/TH&gt;
&lt;TD class="r data"&gt;10&lt;/TD&gt;
&lt;TD class="r data"&gt;5.00&lt;/TD&gt;
&lt;TD class="r data"&gt;200&lt;/TD&gt;
&lt;TD class="r data"&gt;100.00&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;since each pair has a freq table, &lt;STRONG&gt;could you please let me know how to stack all of those freq table&lt;/STRONG&gt;? Then using the stacked freq table, I want to divided "frequency" by 149, and get a "new_pct" variable, the results I wanted will look like the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="582"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="140px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="168.8px"&gt;category&lt;/TD&gt;
&lt;TD width="65.6px"&gt;freq&lt;/TD&gt;
&lt;TD width="65.6px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="70.4px"&gt;pct_new&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="140px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="168.8px"&gt;different resp and both wrong&lt;/TD&gt;
&lt;TD width="65.6px"&gt;35&lt;/TD&gt;
&lt;TD width="65.6px"&gt;149&lt;/TD&gt;
&lt;TD width="70.4px"&gt;0.23&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="140px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="168.8px"&gt;different resp and one of them&lt;/TD&gt;
&lt;TD width="65.6px"&gt;37&lt;/TD&gt;
&lt;TD width="65.6px"&gt;149&lt;/TD&gt;
&lt;TD width="70.4px"&gt;0.25&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="140px"&gt;pair_1_2&lt;/TD&gt;
&lt;TD width="168.8px"&gt;same resp and both correct&lt;/TD&gt;
&lt;TD width="65.6px"&gt;118&lt;/TD&gt;
&lt;TD width="65.6px"&gt;149&lt;/TD&gt;
&lt;TD width="70.4px"&gt;0.79&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="140px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="168.8px"&gt;same resp and both wrong&lt;/TD&gt;
&lt;TD width="65.6px"&gt;10&lt;/TD&gt;
&lt;TD width="65.6px"&gt;149&lt;/TD&gt;
&lt;TD width="70.4px"&gt;0.07&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="140px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="168.8px"&gt;different resp and both wrong&lt;/TD&gt;
&lt;TD width="65.6px"&gt;42&lt;/TD&gt;
&lt;TD width="65.6px"&gt;149&lt;/TD&gt;
&lt;TD width="70.4px"&gt;0.28&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="140px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="168.8px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="65.6px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="65.6px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="70.4px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="140px"&gt;pari_1_3&lt;/TD&gt;
&lt;TD width="168.8px"&gt;different resp and one of them&lt;/TD&gt;
&lt;TD width="65.6px"&gt;34&lt;/TD&gt;
&lt;TD width="65.6px"&gt;149&lt;/TD&gt;
&lt;TD width="70.4px"&gt;0.23&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="140px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="168.8px"&gt;same resp and both correct&lt;/TD&gt;
&lt;TD width="65.6px"&gt;114&lt;/TD&gt;
&lt;TD width="65.6px"&gt;149&lt;/TD&gt;
&lt;TD width="70.4px"&gt;0.77&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="140px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="168.8px"&gt;same resp and both wrong&lt;/TD&gt;
&lt;TD width="65.6px"&gt;10&lt;/TD&gt;
&lt;TD width="65.6px"&gt;149&lt;/TD&gt;
&lt;TD width="70.4px"&gt;0.07&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;P&gt;Many thanks!!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 18:33:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625653#M184418</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-02-18T18:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625658#M184423</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/304931"&gt;@superbug&lt;/a&gt;&amp;nbsp; That looks like you want a Tabulated report(cross) report. Am i correct?&amp;nbsp; If yes, the leads to the utilization of PROC TABULATE / PROC REPORT . If this understanding of mine is correct, You are &lt;STRONG&gt;&lt;U&gt;better off starting a new thread&lt;/U&gt;&lt;/STRONG&gt;&amp;nbsp; mentioning what you HAVE (the outcome of proc freq) and the &lt;STRONG&gt;report design structure&lt;/STRONG&gt; you want.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That would make it easy for your to follow and for respondents to offer pointed answers.&amp;nbsp; People like Ballardw , Reeza are super proficient in Report procedures while I am mostly into video games(aka programming) .&amp;nbsp; Makes sense?&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS&amp;nbsp; Always make sure your IF THENs are properly tested with solutions I offer in this or any other thread because sometimes I write so fast making me a typo champion. lol&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 18:43:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625658#M184423</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-18T18:43:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625673#M184436</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks much for your advice!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 19:09:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/625673#M184436</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-02-18T19:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/658381#M197326</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;a while ago, you help about pick a 2 people from a certain number of people. Now if I want to choose 4 people from a certain number of people, I am trying to modify the code you help, but there are error messages, could you help please. Below is the code for pick 4 people from a certain number of people.&amp;nbsp; Thanks much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data comb1;&lt;BR /&gt;set comb;&lt;BR /&gt;array c col:;&lt;BR /&gt;length cat $30 Pair $20;&lt;BR /&gt;do _i=1 to dim(c)-1;&lt;BR /&gt;do _j=_i+1 to dim(c);&lt;BR /&gt;do _m=_j+1 to dim(c)+1;&lt;BR /&gt;do _n=_m+1 to dim(c)+2;&lt;BR /&gt;k1=c(_i);&lt;BR /&gt;k2=c(_j);&lt;BR /&gt;k3=c(_m);&lt;BR /&gt;k4=c(_n);&lt;BR /&gt;Pair=catx('_','Pair',_i,_j,_m,_n);&lt;BR /&gt;if k1=k2=k3=k4=itemkey then cat="same resp and all correct";&lt;BR /&gt;else if k1=k2=k3=k4^=itemkey then cat="same resp and all wrong";&lt;BR /&gt;else if _i=itemkey or _j=itemkey or _m=itemkey or _n=itemkey then cat="different resp and one of them correct";&lt;BR /&gt;else cat="different resp and all wrong";&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;keep itempos itemkey cat pair;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jun 2020 17:54:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/658381#M197326</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-06-14T17:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/658397#M197331</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/304931"&gt;@superbug&lt;/a&gt;&amp;nbsp; Pleasure is and&amp;nbsp;would be mine if i could help. If it's not urgent, can you hang in there till tomorrow EST (US time ) as I'm doing the&amp;nbsp;weekend chores like laundry and cleaning at the moment. Stay safe&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jun 2020 19:39:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/658397#M197331</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-06-14T19:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/658402#M197333</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for replying my post. Sorry for bothering you on the weekend. Of course I'll wait until you are available.&lt;/P&gt;
&lt;P&gt;Enjoy doing the weekend chores.&lt;/P&gt;
&lt;P&gt;Stay safe!&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jun 2020 20:16:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/658402#M197333</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-06-14T20:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SAS code about this combination</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/659134#M197508</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks much for the explanation and teaching!&lt;/P&gt;
&lt;P&gt;very much appreciate your help!&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 20:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HELP-PLEASE-how-to-write-SAS-code-about-this-combination/m-p/659134#M197508</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-06-15T20:53:28Z</dc:date>
    </item>
  </channel>
</rss>

