<?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: Cross tabbing variables in a range in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Cross-tabbing-variables-in-a-range/m-p/825738#M326142</link>
    <description>&lt;P&gt;Perhaps&lt;/P&gt;
&lt;PRE&gt;proc freq data = have;
table pscscore * (psc1 - psc35)/ list ;
run;&lt;/PRE&gt;
&lt;P&gt;The table statement will take variable lists so psc1- psc35 will attempt to use sequentially numbered variables with a PSC prefix. If there are gaps you have to indicate those. Suppose you don't actually have a Psc24 then use Psc1-Psc23 Psc25-Psc35.&lt;/P&gt;
&lt;P&gt;The parentheses treat a list of variables as a "group". You can use the * to cross two groups. With Pscscore as a single variable this will cross it with all the variables in the list.&lt;/P&gt;
&lt;P&gt;IF you meant that you have multiple Pscscore variables, such as 35 of them you would be entering either macro programming to create parallel values to have one pair per * OR perhaps you might be better off with reshaping the data set to a single score and variable with an indicator of the number and do a BY group with different variables.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jul 2022 16:53:25 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-07-27T16:53:25Z</dc:date>
    <item>
      <title>Cross tabbing variables in a range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cross-tabbing-variables-in-a-range/m-p/825728#M326140</link>
      <description>&lt;P&gt;Hello community. I'd like to cross tab all the variables that have a certain prefix (e.g. psc:) against its summary variable (e.g.&amp;nbsp;pscscore) without having to write:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data = have;&lt;BR /&gt;table pscscore*psc1*psc2*...*psc35/ list ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2022 16:35:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cross-tabbing-variables-in-a-range/m-p/825728#M326140</guid>
      <dc:creator>nd</dc:creator>
      <dc:date>2022-07-27T16:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: Cross tabbing variables in a range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cross-tabbing-variables-in-a-range/m-p/825738#M326142</link>
      <description>&lt;P&gt;Perhaps&lt;/P&gt;
&lt;PRE&gt;proc freq data = have;
table pscscore * (psc1 - psc35)/ list ;
run;&lt;/PRE&gt;
&lt;P&gt;The table statement will take variable lists so psc1- psc35 will attempt to use sequentially numbered variables with a PSC prefix. If there are gaps you have to indicate those. Suppose you don't actually have a Psc24 then use Psc1-Psc23 Psc25-Psc35.&lt;/P&gt;
&lt;P&gt;The parentheses treat a list of variables as a "group". You can use the * to cross two groups. With Pscscore as a single variable this will cross it with all the variables in the list.&lt;/P&gt;
&lt;P&gt;IF you meant that you have multiple Pscscore variables, such as 35 of them you would be entering either macro programming to create parallel values to have one pair per * OR perhaps you might be better off with reshaping the data set to a single score and variable with an indicator of the number and do a BY group with different variables.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2022 16:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cross-tabbing-variables-in-a-range/m-p/825738#M326142</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-27T16:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Cross tabbing variables in a range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cross-tabbing-variables-in-a-range/m-p/825745#M326146</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/66894"&gt;@nd&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe it also helps to reduce the width of the resulting table if you concatenate PSC1, ..., PSC35 in a preliminary step using CAT or CATX (depending on the values of those variables, which I assume are numeric)&lt;FONT face="helvetica"&gt;:&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
psc_all=catx(',', of psc1-psc35);
run;

proc freq data=want;
tables pscscore*psc_all / list;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jul 2022 17:12:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cross-tabbing-variables-in-a-range/m-p/825745#M326146</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-07-27T17:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: Cross tabbing variables in a range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cross-tabbing-variables-in-a-range/m-p/825762#M326152</link>
      <description>&lt;P&gt;Do you really want a 36-dimensional table (which is what the embedded "*" will do)?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, then I would go with the proc summary approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway ;
  class pscscore psc: ;
  output out=want (drop=_type_);;
run;
proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You might want to skip on the proc print part.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2022 18:03:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cross-tabbing-variables-in-a-range/m-p/825762#M326152</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-07-27T18:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Cross tabbing variables in a range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cross-tabbing-variables-in-a-range/m-p/825769#M326155</link>
      <description>&lt;P&gt;Yes, thank you! I wanted a &lt;SPAN&gt;36-dimensional table&amp;nbsp;&lt;/SPAN&gt;to check the recode.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2022 18:16:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cross-tabbing-variables-in-a-range/m-p/825769#M326155</guid>
      <dc:creator>nd</dc:creator>
      <dc:date>2022-07-27T18:16:23Z</dc:date>
    </item>
  </channel>
</rss>

