<?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: Flag Variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Flag-Variables/m-p/616834#M180662</link>
    <description>&lt;P&gt;Yes, thank you for all of your help.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 12 Jan 2020 23:34:46 GMT</pubDate>
    <dc:creator>luvscandy27</dc:creator>
    <dc:date>2020-01-12T23:34:46Z</dc:date>
    <item>
      <title>Flag Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-Variables/m-p/616825#M180653</link>
      <description>&lt;P&gt;I have the following data set below i would like to flag each month if the reg_date falls between that month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id enter_dt reg_date startdate endate extdate&lt;BR /&gt;006 31JUN2017 02FEB2016 30JUN2016 30JUN2017 30SEP2018&lt;BR /&gt;005 31JUN2017 01JUL2017 31MAY2016 31MAY2017 31AUG2018&lt;BR /&gt;007 31JUL2017 25NOV2017 31JUL2016 31JUL2017 31OCT2018&lt;BR /&gt;001 31JAN2017 12MAR2018 31JAN2016 31JAN2017 30APR2018&lt;BR /&gt;002 31JAN2017 05JUN2018 29FEB2016 28FEB2017 31MAY2018&lt;BR /&gt;008 31AUG2017 06AUG2018 31JUL2016 31JUL2017 31OCT2018&lt;BR /&gt;004 31AUG2017 08FEB2018 30APR2016 30APR2017 31JUL2018&lt;BR /&gt;010 31MAR2017 06DEC2018 30NOV2016 30NOV2017 28FEB2019&lt;BR /&gt;003 31APR2017 06MAY2019 29FEB2016 28FEB2017 31MAY2018&lt;BR /&gt;009 31FEB2017 13AUG2019 31OCT2016 31OCT2017 31JAN2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance, I would have M1-M13 (m1=jan, m2=feb, m3=march etc.) and if the reg_date falls between the startdate and endate then&lt;BR /&gt;their would be a flag for that ID in February. Or, if the reg_date falls between the endate and extdate then their would be a flag&lt;BR /&gt;for that date. For example, ID 005 reg date is in July the reg date id not fall between the start and end dates but it did fall between&lt;BR /&gt;the end date and extdate therefore for m7 (July) there would be a flag.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id enter_dt reg_date startdate endate extdate m1 m2 m3 m4.....m7&lt;BR /&gt;006 31JUN2017 02FEB2016 30JUN2016 30JUN2017 30SEP2018 0 1 0 0&lt;BR /&gt;005 31JUN2017 01JUL2017 31MAY2016 31MAY2017 31AUG2018 0 0 0 0 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any assistance would be great I tried the code below but it does not flag for a particular month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data = test1; by reg_date ; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test5;&lt;BR /&gt;set test1;&lt;BR /&gt;by reg_date;&lt;BR /&gt;array month{13} month_1-month_13;&lt;BR /&gt;&lt;BR /&gt;do i = 1 to 13;&lt;BR /&gt;&lt;BR /&gt;if startdate le reg_date le enddate then month{i} = 1;&lt;BR /&gt;else if extdate le reg_date le endate then month{i} = 1;&lt;BR /&gt;else month{i} = 0;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jan 2020 22:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-Variables/m-p/616825#M180653</guid>
      <dc:creator>luvscandy27</dc:creator>
      <dc:date>2020-01-12T22:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Flag Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-Variables/m-p/616826#M180654</link>
      <description>&lt;P&gt;Can we simplify it to:&lt;/P&gt;
&lt;P&gt;if regdate falls between startdate and extdate, record the month of regdate?&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jan 2020 22:40:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-Variables/m-p/616826#M180654</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-01-12T22:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Flag Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-Variables/m-p/616827#M180655</link>
      <description>Absolutely!&lt;BR /&gt;</description>
      <pubDate>Sun, 12 Jan 2020 22:47:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-Variables/m-p/616827#M180655</guid>
      <dc:creator>luvscandy27</dc:creator>
      <dc:date>2020-01-12T22:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: Flag Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-Variables/m-p/616829#M180657</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/255656"&gt;@luvscandy27&lt;/a&gt;&amp;nbsp; &amp;nbsp;By any chance, do you mean this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if startdate&amp;lt;=reg_date&amp;lt;=enddate then month_(month(reg_date)) = 1;
else if enddate&amp;lt;=reg_date&amp;lt;=extdate then  month_(month(reg_date)) = 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set have;
 array month_{13} month_1-month_13;
 do i = 1 to 13; 
  month_(i)=0;
 end;
 if startdate&amp;lt;=reg_date&amp;lt;=enddate then month_(month(reg_date)) = 1;
else if enddate&amp;lt;=reg_date&amp;lt;=extdate then  month_(month(reg_date)) = 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 Jan 2020 22:51:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-Variables/m-p/616829#M180657</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-12T22:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Flag Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-Variables/m-p/616830#M180658</link>
      <description>&lt;P&gt;Yes, that works thank you so much. I just have one more question is there anyway that i could get a sum of each month using the same data step or even a new data step?&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jan 2020 23:00:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-Variables/m-p/616830#M180658</guid>
      <dc:creator>luvscandy27</dc:creator>
      <dc:date>2020-01-12T23:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: Flag Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-Variables/m-p/616831#M180659</link>
      <description>&lt;P&gt;Hi again&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/255656"&gt;@luvscandy27&lt;/a&gt;&amp;nbsp; &amp;nbsp;Do you mean this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;sum=sum(of month_1-month_13);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;U&gt;Full Version:&lt;/U&gt;&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 month_{13} month_1-month_13;
 do i = 1 to 13; 
  month_(i)=0;
 end;
 if startdate&amp;lt;=reg_date&amp;lt;=enddate then month_(month(reg_date)) = 1;
else if enddate&amp;lt;=reg_date&amp;lt;=extdate then  month_(month(reg_date)) = 1;
sum=sum(of month_1-month_13);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 Jan 2020 23:04:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-Variables/m-p/616831#M180659</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-12T23:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Flag Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-Variables/m-p/616834#M180662</link>
      <description>&lt;P&gt;Yes, thank you for all of your help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jan 2020 23:34:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-Variables/m-p/616834#M180662</guid>
      <dc:creator>luvscandy27</dc:creator>
      <dc:date>2020-01-12T23:34:46Z</dc:date>
    </item>
  </channel>
</rss>

