<?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: Dummies vs. CLASS function in PROC GLMSELECT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dummies-vs-CLASS-function-in-PROC-GLMSELECT/m-p/640093#M190561</link>
    <description>&lt;P&gt;Yes, you should use the CLASS statement rather than create your own dummy variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, I get the feeling I am missing the point of your question.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Apr 2020 13:02:23 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-04-15T13:02:23Z</dc:date>
    <item>
      <title>Dummies vs. CLASS function in PROC GLMSELECT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dummies-vs-CLASS-function-in-PROC-GLMSELECT/m-p/640089#M190558</link>
      <description>&lt;P&gt;Hi All, I am working with medical claims data and recreated a small sample below called have. I'd like to run regressions to predict the value variable and take into account whether a claim_id had a certain procedure (proc_cd) or not via dummy variables. My data is in wide format, and if I used the CLASS function, I don't care about the variable proc_cd1, proc_cd2, etc. separately. What I do care about is for a given proc_cd, did the claim_id have that proc_cd associated with it or not. So basically creating dummies across all of the proc_cd values. I have a lot of proc_cd values in my real dataset so I would like to avoid writing them all out to create the dummies manually. Any suggestions on how to resolve this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data have;&lt;BR /&gt;input claim_id $ proc_cd1 $ proc_cd2 $ proc_cd3 $ proc_cd4 $ value age hr;&lt;BR /&gt;cards;&lt;BR /&gt;2 234 443 J21 J21 234 23 60&lt;BR /&gt;7 J1 J302 J232 J454 45645 43 69&lt;BR /&gt;3 J204 543 678 . 3456 45 78&lt;BR /&gt;5 J21 J22 . . 234 67 89&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 12:53:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dummies-vs-CLASS-function-in-PROC-GLMSELECT/m-p/640089#M190558</guid>
      <dc:creator>PeterBr</dc:creator>
      <dc:date>2020-04-15T12:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: Dummies vs. CLASS function in PROC GLMSELECT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dummies-vs-CLASS-function-in-PROC-GLMSELECT/m-p/640093#M190561</link>
      <description>&lt;P&gt;Yes, you should use the CLASS statement rather than create your own dummy variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, I get the feeling I am missing the point of your question.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 13:02:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dummies-vs-CLASS-function-in-PROC-GLMSELECT/m-p/640093#M190561</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-15T13:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: Dummies vs. CLASS function in PROC GLMSELECT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dummies-vs-CLASS-function-in-PROC-GLMSELECT/m-p/640115#M190577</link>
      <description>&lt;P&gt;I am going to guess that in this case you need to create indicator variables because the value of interest could occur in multiple variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example of one way to search a list of Prod_cd variables for a given value and create a 1/0 coded value for when found or not.&lt;/P&gt;
&lt;PRE&gt;data have;
input claim_id $ proc_cd1 $ proc_cd2 $ proc_cd3 $ proc_cd4 $ value age hr;
   array p proc_cd: ;
   VJ21 = whichc('J21',of p(*)) &amp;gt; 0;
cards;
2 234 443 J21 J21 234 23 60
7 J1 J302 J232 J454 45645 43 69
3 J204 543 678 . 3456 45 78
5 J21 J22 . . 234 67 89
;
run;&lt;/PRE&gt;
&lt;P&gt;The Whichc , or the numeric counterpart Whichn, searches for the first value in a list of variables/values following and returns the numeric position in the list a value match is found or 0 if not found. SAS returns 1 for true and 0 for false for logical comparisons so the &amp;gt; 0 above returns 1 when the match is found when looking for the value 'J21';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This could be done with a temporary array to hold the values and another array to hold results&lt;/P&gt;
&lt;PRE&gt;data have;
input claim_id $ proc_cd1 $ proc_cd2 $ proc_cd3 $ proc_cd4 $ value age hr;
   array p proc_cd: ;
   array v (3) $ 4 _temporary_ ('J21' 'J232' '678');
   array r (3);
   do i= 1 to dim(v);
      r[i] = whichc(v[i],of p(*)) &amp;gt; 0;
   end;
   drop i;
cards;
2 234 443 J21 J21 234 23 60
7 J1 J302 J232 J454 45645 43 69
3 J204 543 678 . 3456 45 78
5 J21 J22 . . 234 67 89
;
run;&lt;/PRE&gt;
&lt;P&gt;It would be up to you to keep track that r1 is related to the value 'J21'.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 14:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dummies-vs-CLASS-function-in-PROC-GLMSELECT/m-p/640115#M190577</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-15T14:42:17Z</dc:date>
    </item>
  </channel>
</rss>

