<?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 Generate combinations of categorical variables with varying levels in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Generate-combinations-of-categorical-variables-with-varying/m-p/202603#M50558</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a dataset with five categorical variables.&lt;/P&gt;&lt;P&gt;V1 have 3 levels: CO, KY, NY&lt;/P&gt;&lt;P&gt;V2 have 2 levels: A, F&lt;/P&gt;&lt;P&gt;V3 have 2 levels: H, P&lt;/P&gt;&lt;P&gt;V4 have 2 levels: C, P&lt;/P&gt;&lt;P&gt;V5 have 4 levels: A, B, C, D&lt;/P&gt;&lt;P&gt;The data below shows all combinations we observed. Based on this dataset, how I can find all valid combinations of different levels of these variables?&lt;/P&gt;&lt;P&gt;What I am looking for is combinations like [CO].&lt;A&gt;.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;.&lt;C&gt;.&lt;D&gt;, OR [CO].[A.F].&lt;/D&gt;&lt;/C&gt;&lt;/P&gt;&lt;P&gt;.&lt;C&gt;.&lt;D&gt;, OR [CO.KY].&lt;A&gt;.&lt;/A&gt;&lt;/D&gt;&lt;/C&gt;&lt;/P&gt;&lt;P&gt;.&lt;C&gt;.&lt;D&gt;, OR [CO.KY.NY].].&lt;A&gt;.&lt;/A&gt;&lt;/D&gt;&lt;/C&gt;&lt;/P&gt;&lt;P&gt;.&lt;C&gt;.[A.B.C.D]. For each variable, I can take one or multiple levels, but I want to make sure that the combination is represented in the data. For example, [KY].&lt;A&gt;.&lt;/A&gt;&lt;/C&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;A&gt; is not a valid combination. When multiple levels selected, order is not important. So A.B.D is the same as B.D.A.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How should I write my program to list all valid combinations? Any suggestion are highly appreciated. Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;V1 V2 V3 V4 V5&lt;/P&gt;&lt;P&gt;CO A P C D&lt;/P&gt;&lt;P&gt;CO F H C D&lt;/P&gt;&lt;P&gt;CO F P C D&lt;/P&gt;&lt;P&gt;KY A P C D&lt;/P&gt;&lt;P&gt;KY F H C D&lt;/P&gt;&lt;P&gt;KY F P C D&lt;/P&gt;&lt;P&gt;NY A P C D&lt;/P&gt;&lt;P&gt;NY A P P A&lt;/P&gt;&lt;P&gt;NY A P P B&lt;/P&gt;&lt;P&gt;NY A P P C&lt;/P&gt;&lt;P&gt;NY A P P D&lt;/P&gt;&lt;P&gt;NY F H C D&lt;/P&gt;&lt;P&gt;NY F H P A&lt;/P&gt;&lt;P&gt;NY F H P B&lt;/P&gt;&lt;P&gt;NY F H P C&lt;/P&gt;&lt;P&gt;NY F H P D&lt;/P&gt;&lt;P&gt;NY F P C D&lt;/P&gt;&lt;P&gt;NY F P P A&lt;/P&gt;&lt;P&gt;NY F P P B&lt;/P&gt;&lt;P&gt;NY F P P C&lt;/P&gt;&lt;P&gt;NY F P P D&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Apr 2015 19:19:11 GMT</pubDate>
    <dc:creator>HuiZ</dc:creator>
    <dc:date>2015-04-23T19:19:11Z</dc:date>
    <item>
      <title>Generate combinations of categorical variables with varying levels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-combinations-of-categorical-variables-with-varying/m-p/202603#M50558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a dataset with five categorical variables.&lt;/P&gt;&lt;P&gt;V1 have 3 levels: CO, KY, NY&lt;/P&gt;&lt;P&gt;V2 have 2 levels: A, F&lt;/P&gt;&lt;P&gt;V3 have 2 levels: H, P&lt;/P&gt;&lt;P&gt;V4 have 2 levels: C, P&lt;/P&gt;&lt;P&gt;V5 have 4 levels: A, B, C, D&lt;/P&gt;&lt;P&gt;The data below shows all combinations we observed. Based on this dataset, how I can find all valid combinations of different levels of these variables?&lt;/P&gt;&lt;P&gt;What I am looking for is combinations like [CO].&lt;A&gt;.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;.&lt;C&gt;.&lt;D&gt;, OR [CO].[A.F].&lt;/D&gt;&lt;/C&gt;&lt;/P&gt;&lt;P&gt;.&lt;C&gt;.&lt;D&gt;, OR [CO.KY].&lt;A&gt;.&lt;/A&gt;&lt;/D&gt;&lt;/C&gt;&lt;/P&gt;&lt;P&gt;.&lt;C&gt;.&lt;D&gt;, OR [CO.KY.NY].].&lt;A&gt;.&lt;/A&gt;&lt;/D&gt;&lt;/C&gt;&lt;/P&gt;&lt;P&gt;.&lt;C&gt;.[A.B.C.D]. For each variable, I can take one or multiple levels, but I want to make sure that the combination is represented in the data. For example, [KY].&lt;A&gt;.&lt;/A&gt;&lt;/C&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;A&gt; is not a valid combination. When multiple levels selected, order is not important. So A.B.D is the same as B.D.A.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How should I write my program to list all valid combinations? Any suggestion are highly appreciated. Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;V1 V2 V3 V4 V5&lt;/P&gt;&lt;P&gt;CO A P C D&lt;/P&gt;&lt;P&gt;CO F H C D&lt;/P&gt;&lt;P&gt;CO F P C D&lt;/P&gt;&lt;P&gt;KY A P C D&lt;/P&gt;&lt;P&gt;KY F H C D&lt;/P&gt;&lt;P&gt;KY F P C D&lt;/P&gt;&lt;P&gt;NY A P C D&lt;/P&gt;&lt;P&gt;NY A P P A&lt;/P&gt;&lt;P&gt;NY A P P B&lt;/P&gt;&lt;P&gt;NY A P P C&lt;/P&gt;&lt;P&gt;NY A P P D&lt;/P&gt;&lt;P&gt;NY F H C D&lt;/P&gt;&lt;P&gt;NY F H P A&lt;/P&gt;&lt;P&gt;NY F H P B&lt;/P&gt;&lt;P&gt;NY F H P C&lt;/P&gt;&lt;P&gt;NY F H P D&lt;/P&gt;&lt;P&gt;NY F P C D&lt;/P&gt;&lt;P&gt;NY F P P A&lt;/P&gt;&lt;P&gt;NY F P P B&lt;/P&gt;&lt;P&gt;NY F P P C&lt;/P&gt;&lt;P&gt;NY F P P D&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2015 19:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-combinations-of-categorical-variables-with-varying/m-p/202603#M50558</guid>
      <dc:creator>HuiZ</dc:creator>
      <dc:date>2015-04-23T19:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Generate combinations of categorical variables with varying levels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-combinations-of-categorical-variables-with-varying/m-p/202604#M50559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would start with something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data= have ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tables v1* v2* v3 *v4* v5/list nocum nopercent;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;If I need an output data set then add an OUT=want to the tables statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2015 20:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-combinations-of-categorical-variables-with-varying/m-p/202604#M50559</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-04-23T20:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Generate combinations of categorical variables with varying levels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-combinations-of-categorical-variables-with-varying/m-p/202605#M50560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply! Actually, the dataset I listed there is the output from the proc freq on a larger dataset. But that only give me the combinations with one level from each variable. I'm looking for a way to grab multiple levels from each variable. For example, for V2, it can take the form of A, F or (A, F). For V1, it can take CO, KY, NY, (CO, KY), (CO, NY), (KY, NY) OR (CO, KY, NY). I have actually figured out a way to list all POSSIBLE combinations like this, but the part that I got stuck is how to identify the valid combinations out of all possible combinations. As I mentioned, [KY].&lt;A&gt;.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;A&gt; is not a valid combination as it didn't show up in the data. The single level combinations are easy, but when it is multiple levels combined, how do I verify if it's valid or not?&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2015 21:06:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-combinations-of-categorical-variables-with-varying/m-p/202605#M50560</guid>
      <dc:creator>HuiZ</dc:creator>
      <dc:date>2015-04-23T21:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Generate combinations of categorical variables with varying levels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-combinations-of-categorical-variables-with-varying/m-p/202606#M50561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you have to explain what [CO.KY].&lt;A&gt;.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;.&lt;C&gt;.&lt;D&gt;, means as I wouldn't think that what you imply with [CO.KY] is possible to occur in your data. That would mean that a variable has 2 values for a single record?&lt;/D&gt;&lt;/C&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe you should provide a small example dataset with 3 variables and then show what result you are expecting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2015 22:18:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-combinations-of-categorical-variables-with-varying/m-p/202606#M50561</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-04-23T22:18:11Z</dc:date>
    </item>
  </channel>
</rss>

