<?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 how to create dummy variable from the variable that has a lot different values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-dummy-variable-from-the-variable-that-has-a-lot/m-p/459225#M116615</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a variable that consists information about diagnosis (6496 different diagnosis). For each diagnosis i want to create a dummy variable and i used this code:&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;DATA b2;
  set b;
 
  ARRAY dummys {*} 3.  diag1_1 - diag1_6496;
 
  DO i=1 TO 6496;			      
    dummys(i) = 0;
  END;
  dummys( diag1  ) = 1;		
 
RUN;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;However, I get this error message:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Array subscript out of range at line 2087 column 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone tel me what is wrong with code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you&lt;/P&gt;</description>
    <pubDate>Wed, 02 May 2018 10:30:30 GMT</pubDate>
    <dc:creator>viollete</dc:creator>
    <dc:date>2018-05-02T10:30:30Z</dc:date>
    <item>
      <title>how to create dummy variable from the variable that has a lot different values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-dummy-variable-from-the-variable-that-has-a-lot/m-p/459225#M116615</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a variable that consists information about diagnosis (6496 different diagnosis). For each diagnosis i want to create a dummy variable and i used this code:&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;DATA b2;
  set b;
 
  ARRAY dummys {*} 3.  diag1_1 - diag1_6496;
 
  DO i=1 TO 6496;			      
    dummys(i) = 0;
  END;
  dummys( diag1  ) = 1;		
 
RUN;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;However, I get this error message:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Array subscript out of range at line 2087 column 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone tel me what is wrong with code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 10:30:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-dummy-variable-from-the-variable-that-has-a-lot/m-p/459225#M116615</guid>
      <dc:creator>viollete</dc:creator>
      <dc:date>2018-05-02T10:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to create dummy variable from the variable that has a lot different values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-dummy-variable-from-the-variable-that-has-a-lot/m-p/459229#M116616</link>
      <description>&lt;P&gt;With such errors, you get a listing of all variables and their values in the log. Look for the value of diag1. It might be zero or missing.&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 10:41:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-dummy-variable-from-the-variable-that-has-a-lot/m-p/459229#M116616</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-02T10:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to create dummy variable from the variable that has a lot different values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-dummy-variable-from-the-variable-that-has-a-lot/m-p/459230#M116617</link>
      <description>&lt;P&gt;Obviously, the value of the DIAG1 variable is not always between 1 and 6496. Is it missing or 0 in some observations? What does the log say about the value of DIAG1 when the error occurs?&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 10:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-dummy-variable-from-the-variable-that-has-a-lot/m-p/459230#M116617</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-05-02T10:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to create dummy variable from the variable that has a lot different values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-dummy-variable-from-the-variable-that-has-a-lot/m-p/459231#M116618</link>
      <description>&lt;P&gt;Still better: run a proc freq on diag1 and inspect the result.&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 10:43:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-dummy-variable-from-the-variable-that-has-a-lot/m-p/459231#M116618</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-02T10:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to create dummy variable from the variable that has a lot different values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-dummy-variable-from-the-variable-that-has-a-lot/m-p/459234#M116620</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;There is no 0 or missing values; however, I found what was wrong with code (my values were letters not numbers) and I made it work&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 10:47:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-dummy-variable-from-the-variable-that-has-a-lot/m-p/459234#M116620</guid>
      <dc:creator>viollete</dc:creator>
      <dc:date>2018-05-02T10:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to create dummy variable from the variable that has a lot different values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-dummy-variable-from-the-variable-that-has-a-lot/m-p/459249#M116627</link>
      <description>&lt;P&gt;I would question why you want to do this.&amp;nbsp; Just take a simple example of having two records:&lt;/P&gt;
&lt;P&gt;DIAG&lt;/P&gt;
&lt;P&gt;34&lt;/P&gt;
&lt;P&gt;26&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is two datapoints of information.&amp;nbsp; If you transpose that into your structure, you would have 6496 datapoints of information.&amp;nbsp; This is just a simple example of where your intended data structure is very verbose in terms of storage, but you will also find your coding is far harder as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 11:14:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-dummy-variable-from-the-variable-that-has-a-lot/m-p/459249#M116627</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-02T11:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to create dummy variable from the variable that has a lot different values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-dummy-variable-from-the-variable-that-has-a-lot/m-p/459297#M116644</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
set sashelp.class;
dummy=1;
run;
proc logistic data=have outdesign=want outdesignonly;
class name/param=glm;
model dummy=name;
run;

proc print data=want(drop=dummy intercept) noobs;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 May 2018 13:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-dummy-variable-from-the-variable-that-has-a-lot/m-p/459297#M116644</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-05-02T13:24:20Z</dc:date>
    </item>
  </channel>
</rss>

