<?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: Generating Indicator Variables using age ranges in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Generating-Indicator-Variables-using-age-ranges/m-p/571669#M17544</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256379"&gt;@bgosiker&lt;/a&gt;&amp;nbsp;- the program as posted by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274358"&gt;@arthurcavila&lt;/a&gt;&amp;nbsp;works fine for me. You have obviously changed it so post the code you are trying to run.&lt;/P&gt;</description>
    <pubDate>Sun, 07 Jul 2019 21:18:02 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2019-07-07T21:18:02Z</dc:date>
    <item>
      <title>Generating Indicator Variables using age ranges</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Generating-Indicator-Variables-using-age-ranges/m-p/571586#M17541</link>
      <description>&lt;P&gt;Hi Everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a long dataset (multiple rows per person), and each row has a "start age" and "end age" to indicate the 0.5 year age range that the row is meant to represent. Ie someone would have age_start=20 and age_end=20.5. My LOWEST age_start is 17.5 and my highest age_end is 93, so there is at least one person for each 0.5 year increment between 17.5 and 93.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wanting to generate time indicators based on these age ranges so that I can align everyone on the basis of age. Some people have gaps in visit (note, ID=2 is missing visit=3, so there is a gap!). Basically starting with age_start=17.5 I would want some indicator variable (let's say age_X) to be age_X=0 and then increase by 1 for each progressive 0.5 years (ie for age_start=18 age_0=0 and age_1=1). So each row should only have ONE age_x variable that is 1 and all the others would be 0. There should be 151 indicator variables generated from this for each 0.5 year range between 17.5 and 93.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think an array would be the best approach here, but was unsure how to get it to be based specifically on the age_start variable since each person can start at a different age and there can be gaps. Any help is appreciated!&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example of the data I have is below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;Data&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;ID&lt;/SPAN&gt;  visit age_start age_end &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token keyword"&gt;datalines&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token data string"&gt;1  1  17.5  18
1  2  18  18.5
1  3  18.5  19
2  1  25  25.5
2  2  25.5 26
2  4  26.5  27
3  1  51.5  52
3  2  52  52.5
3  3  52.5  53&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data I &lt;U&gt;&lt;STRONG&gt;WANT:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id&amp;nbsp; &amp;nbsp; &amp;nbsp;visit&amp;nbsp; &amp;nbsp; age_start&amp;nbsp; &amp;nbsp; age_end&amp;nbsp; &amp;nbsp; age0&amp;nbsp; &amp;nbsp; age1&amp;nbsp; &amp;nbsp; &amp;nbsp; age2.....&amp;nbsp; age15&amp;nbsp; age16&amp;nbsp; &amp;nbsp;age17&amp;nbsp; &amp;nbsp; age18......age68&amp;nbsp; &amp;nbsp; age69&amp;nbsp; &amp;nbsp; ag70.......&lt;/P&gt;&lt;P&gt;&lt;FONT face="monospace"&gt;1&amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;17.5&amp;nbsp; &amp;nbsp; &amp;nbsp;18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="monospace"&gt;&amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18.5&amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="monospace"&gt;1&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;3&amp;nbsp; &amp;nbsp; &amp;nbsp;18.5&amp;nbsp; &amp;nbsp; &amp;nbsp;19&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;0&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="monospace"&gt;2&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp;25&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;25.5&amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;0&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="monospace"&gt;2&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;25.5&amp;nbsp; &amp;nbsp; &amp;nbsp;26&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;0&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="monospace"&gt;2&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;4&amp;nbsp; &amp;nbsp; &amp;nbsp;26.5&amp;nbsp; &amp;nbsp; &amp;nbsp;27&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;0&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="monospace"&gt;3&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp;51.5&amp;nbsp; &amp;nbsp; &amp;nbsp;52&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;0&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="monospace"&gt;3&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;52&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;52.5&amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;0&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="monospace"&gt;3&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;3&amp;nbsp; &amp;nbsp; &amp;nbsp;52.5&amp;nbsp; &amp;nbsp; &amp;nbsp;53&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jul 2019 16:13:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Generating-Indicator-Variables-using-age-ranges/m-p/571586#M17541</guid>
      <dc:creator>bgosiker</dc:creator>
      <dc:date>2019-07-06T16:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Indicator Variables using age ranges</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Generating-Indicator-Variables-using-age-ranges/m-p/571589#M17542</link>
      <description>&lt;P&gt;My first question would be why do you need those dummy variables? Procedures with a CLASS statement will generate the dummies you need internally.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Data have;
 input ID  visit age_start age_end ;
 array age{151} age1-age151;
 do i = 1 to 151;
 	if i = (age_start-17)*2 then age{i} = 1;
 	else age{i} = 0;
 end;
 drop i;
datalines;
1  1  17.5  18
1  2  18  18.5
1  3  18.5  19
2  1  25  25.5
2  2  25.5 26
2  4  26.5  27
3  1  51.5  52
3  2  52  52.5
3  3  52.5  53
;
run;&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Jul 2019 17:10:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Generating-Indicator-Variables-using-age-ranges/m-p/571589#M17542</guid>
      <dc:creator>arthurcavila</dc:creator>
      <dc:date>2019-07-06T17:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Indicator Variables using age ranges</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Generating-Indicator-Variables-using-age-ranges/m-p/571668#M17543</link>
      <description>&lt;P&gt;I was needing to export my data to run analyses in Stata so thought I needed to generate the indicator variables for it. I tried running the code you gave and ran into an issue where the data step wasn't finishing and eventually had to break it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jul 2019 21:01:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Generating-Indicator-Variables-using-age-ranges/m-p/571668#M17543</guid>
      <dc:creator>bgosiker</dc:creator>
      <dc:date>2019-07-07T21:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Indicator Variables using age ranges</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Generating-Indicator-Variables-using-age-ranges/m-p/571669#M17544</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256379"&gt;@bgosiker&lt;/a&gt;&amp;nbsp;- the program as posted by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274358"&gt;@arthurcavila&lt;/a&gt;&amp;nbsp;works fine for me. You have obviously changed it so post the code you are trying to run.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jul 2019 21:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Generating-Indicator-Variables-using-age-ranges/m-p/571669#M17544</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-07-07T21:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Indicator Variables using age ranges</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Generating-Indicator-Variables-using-age-ranges/m-p/571670#M17545</link>
      <description>&lt;P&gt;Doesn't STATA generate indicator variables when you try to fit a model? Doesn't SAS give the ability to run the same models?&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jul 2019 21:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Generating-Indicator-Variables-using-age-ranges/m-p/571670#M17545</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-07T21:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Indicator Variables using age ranges</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Generating-Indicator-Variables-using-age-ranges/m-p/571672#M17546</link>
      <description>Dumb mistake - left off the run when I copied over!</description>
      <pubDate>Sun, 07 Jul 2019 22:18:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Generating-Indicator-Variables-using-age-ranges/m-p/571672#M17546</guid>
      <dc:creator>bgosiker</dc:creator>
      <dc:date>2019-07-07T22:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Indicator Variables using age ranges</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Generating-Indicator-Variables-using-age-ranges/m-p/571673#M17547</link>
      <description>I wasn't sure if stata did and I'll be switching from a PC (with SAS) to a mac (with stata) in the coming days and wanted to make sure I was prepared if it didn't. If it does then that is great!</description>
      <pubDate>Sun, 07 Jul 2019 22:19:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Generating-Indicator-Variables-using-age-ranges/m-p/571673#M17547</guid>
      <dc:creator>bgosiker</dc:creator>
      <dc:date>2019-07-07T22:19:17Z</dc:date>
    </item>
  </channel>
</rss>

