<?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 Categorize multiple variables based on mean and sd in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Categorize-multiple-variables-based-on-mean-and-sd/m-p/348476#M273411</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I need to categorize&amp;nbsp;many variables (var1-var9) based on the mean and SD. I would like to ask for syntax (macro?) to do these faster and more accurate.&lt;/P&gt;&lt;P&gt;///&lt;/P&gt;&lt;P&gt;var1_3cat=.;&lt;/P&gt;&lt;P&gt;if var1 &amp;lt; (mean-sd) then&amp;nbsp;&lt;SPAN&gt;var1_3cat=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if var1 &amp;gt;=&amp;nbsp;(mean-sd) &amp;amp; var1 &amp;lt;=&amp;nbsp;(mean+sd) then&amp;nbsp;var1_3cat=2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if var1 &amp;gt;(mean+sd) then&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;var1_3cat=3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;///&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;haoduonge&lt;/P&gt;</description>
    <pubDate>Sun, 09 Apr 2017 04:13:14 GMT</pubDate>
    <dc:creator>haoduonge</dc:creator>
    <dc:date>2017-04-09T04:13:14Z</dc:date>
    <item>
      <title>Categorize multiple variables based on mean and sd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Categorize-multiple-variables-based-on-mean-and-sd/m-p/348476#M273411</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I need to categorize&amp;nbsp;many variables (var1-var9) based on the mean and SD. I would like to ask for syntax (macro?) to do these faster and more accurate.&lt;/P&gt;&lt;P&gt;///&lt;/P&gt;&lt;P&gt;var1_3cat=.;&lt;/P&gt;&lt;P&gt;if var1 &amp;lt; (mean-sd) then&amp;nbsp;&lt;SPAN&gt;var1_3cat=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if var1 &amp;gt;=&amp;nbsp;(mean-sd) &amp;amp; var1 &amp;lt;=&amp;nbsp;(mean+sd) then&amp;nbsp;var1_3cat=2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if var1 &amp;gt;(mean+sd) then&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;var1_3cat=3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;///&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;haoduonge&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2017 04:13:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Categorize-multiple-variables-based-on-mean-and-sd/m-p/348476#M273411</guid>
      <dc:creator>haoduonge</dc:creator>
      <dc:date>2017-04-09T04:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Categorize multiple variables based on mean and sd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Categorize-multiple-variables-based-on-mean-and-sd/m-p/348478#M273412</link>
      <description>&lt;P&gt;How are the mean and sd calculated? Are they unique to each variable or from a population value or from all of the variables?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may not need a macro, look at proc stdize/standard to standardize the variables which is essentially what you're trying to do here.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2017 04:30:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Categorize-multiple-variables-based-on-mean-and-sd/m-p/348478#M273412</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-09T04:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Categorize multiple variables based on mean and sd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Categorize-multiple-variables-based-on-mean-and-sd/m-p/348479#M273413</link>
      <description>&lt;P&gt;Mean and SD are calulated from proc means and &lt;SPAN&gt;unique to each variable.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2017 04:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Categorize-multiple-variables-based-on-mean-and-sd/m-p/348479#M273413</guid>
      <dc:creator>haoduonge</dc:creator>
      <dc:date>2017-04-09T04:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Categorize multiple variables based on mean and sd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Categorize-multiple-variables-based-on-mean-and-sd/m-p/348480#M273414</link>
      <description>&lt;P&gt;I would simply create an informat and calculate zscores and apply the informat to that calculation. e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format;
  invalue zcat
  .=.
  low-&amp;lt; -1=1
  1.0000000001-high=3
  other=2
  ;
run;
data have;
  input score;
  mean=6;
  std=2;
  var1_3cat=input((score-mean)/std, zcat.);
  cards;
2
3
4
.
5
6
7
8
9
10
;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2017 04:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Categorize-multiple-variables-based-on-mean-and-sd/m-p/348480#M273414</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-09T04:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Categorize multiple variables based on mean and sd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Categorize-multiple-variables-based-on-mean-and-sd/m-p/348481#M273415</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138243"&gt;@haoduonge&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Mean and SD are calulated from proc means and &lt;SPAN&gt;unique to each variable.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Proc stdize is a good option. Look at the METHOD options on the PROC statement.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2017 05:06:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Categorize-multiple-variables-based-on-mean-and-sd/m-p/348481#M273415</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-09T05:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Categorize multiple variables based on mean and sd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Categorize-multiple-variables-based-on-mean-and-sd/m-p/348498#M273416</link>
      <description>&lt;PRE&gt;
It is very easy for IML code.


proc iml;
use sashelp.class;
read all var _num_ into x[c=vname];
close;

mean=mean(x);
std=std(x);

want=j(nrow(x),ncol(x),.);
do i=1 to ncol(x);
  cutpoint=min(x[,i])||(mean[i]-std[i])||(mean[i]+std[i])||max(x[,i]);
  want[,i]=bin(x[,i],cutpoint);
end;

print want[c=vname];

run;


&lt;/PRE&gt;</description>
      <pubDate>Sun, 09 Apr 2017 11:34:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Categorize-multiple-variables-based-on-mean-and-sd/m-p/348498#M273416</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-09T11:34:06Z</dc:date>
    </item>
  </channel>
</rss>

