<?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: Base SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/243997#M45427</link>
    <description>&lt;P&gt;You could also use an ARRAY to help with making dummy variables. &amp;nbsp;So if X has 7 values (1 to 7) then this code will make variables DUMMY1 to DUMMY7 with 0/1 values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  array dummy (7);
  do i=1 to dim(dummy);
     dummy(i)=(x=i);
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that if X is not simply the values 1 to 7 then it is a little harder. &amp;nbsp;You should look at the GLMMOD procedure as a way to generate dummy variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Jan 2016 15:28:20 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2016-01-16T15:28:20Z</dc:date>
    <item>
      <title>Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/243995#M45426</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The below code will mark each zero across the variables V1 to V10 (Column) as missing value (.dot)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data credit;&lt;BR /&gt;set file;&lt;BR /&gt;array x(*) V1&amp;nbsp;-- V10;&lt;BR /&gt;do i=1 to dim(x);&lt;BR /&gt;if x(i)=0 then x(i)=.;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's say in regression analysis while creating dummy variables, X variable has 7 categories and I would like to create dummy variables for those 7 categories.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I write codes using array or macros to create dummy variables, Is it possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Need help.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jan 2016 15:16:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/243995#M45426</guid>
      <dc:creator>KafeelBasha</dc:creator>
      <dc:date>2016-01-16T15:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/243997#M45427</link>
      <description>&lt;P&gt;You could also use an ARRAY to help with making dummy variables. &amp;nbsp;So if X has 7 values (1 to 7) then this code will make variables DUMMY1 to DUMMY7 with 0/1 values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  array dummy (7);
  do i=1 to dim(dummy);
     dummy(i)=(x=i);
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that if X is not simply the values 1 to 7 then it is a little harder. &amp;nbsp;You should look at the GLMMOD procedure as a way to generate dummy variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jan 2016 15:28:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/243997#M45427</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-01-16T15:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/244006#M45428</link>
      <description>&lt;P&gt;Assuming X is numeric, you don't need to know the number of values ahead of time. &amp;nbsp;Here is the idea:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;/P&gt;
&lt;P&gt;select distinct X into : list_of_x separated by ' ' from have;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;%do i=1 %to &amp;amp;sqlobs;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;dummy&amp;amp;i = (x=%scan(&amp;amp;list_of_x, &amp;amp;i));&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, you will need to define a macro to hold the logic, because of the %DO loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jan 2016 17:18:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/244006#M45428</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-16T17:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/244037#M45444</link>
      <description>Also, depending on the Proc SAS may calculate the dummy variables for you. The CLASS statement is the common method, make sure to understand which method of dummy variable is being used if you do use the Class statement. The default is GLM coding rather than reference coding.</description>
      <pubDate>Sun, 17 Jan 2016 02:48:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/244037#M45444</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-17T02:48:59Z</dc:date>
    </item>
  </channel>
</rss>

