<?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: Creating a 'Class Variable' for Observations in a Specified Time Period. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448855#M283478</link>
    <description>&lt;P&gt;Thank you, Patrick. Your suggestion was helpful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I modified the code a little more to ensure variables in each class are &lt;STRONG&gt;within the specified time period.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made use of:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data xx;&lt;BR /&gt;set x;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Startdate1 = '15May2011'd - 30;&lt;BR /&gt;Enddate1 = '15May2011'd;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Startdate2 = '16May2011'd;&lt;BR /&gt;Enddate2 = '16May2011'd + 30;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If Startdate1 &amp;lt; date &amp;lt; Enddate1 then flag=0;&lt;BR /&gt;If Startdate2 &amp;lt; date &amp;lt; Enddate2 then flag=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This worked fine for me. I'm&amp;nbsp;still learning most of these little manipulations. Thank you for your help once more!&lt;/P&gt;</description>
    <pubDate>Tue, 27 Mar 2018 04:02:00 GMT</pubDate>
    <dc:creator>arii</dc:creator>
    <dc:date>2018-03-27T04:02:00Z</dc:date>
    <item>
      <title>Creating a 'Class Variable' for Observations in a Specified Time Period.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448531#M283472</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a 'Class Variable' for &lt;STRONG&gt;only&lt;/STRONG&gt; observations within a specific time period (&lt;STRONG&gt;30 days before 15-May-2012&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;an&lt;STRONG&gt;d 30 days after 16-May-2012&lt;/STRONG&gt;). However, the output of my code seems to include observations that are not within this specified time period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm&amp;nbsp;a little confused here, I probably did not write my codes properly. Please see below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SAS Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data xx;&lt;BR /&gt;set x;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Startdate = '15May2012'd - 30;&lt;BR /&gt;Enddate = '16May2012'd + 30;&lt;/P&gt;&lt;P&gt;If Startdate &amp;lt;= date then flag=1;&lt;BR /&gt;If Enddate &amp;gt; date then flag = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in anticipation!&lt;/P&gt;</description>
      <pubDate>Sun, 25 Mar 2018 22:53:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448531#M283472</guid>
      <dc:creator>arii</dc:creator>
      <dc:date>2018-03-25T22:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 'Class Variable' for Observations in a Specified Time Period.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448532#M283473</link>
      <description>&lt;P&gt;I trued the code below too. The outputs are still kinda the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data xx;&lt;BR /&gt;set x;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Startdate = '15May2012'd - 30;&lt;BR /&gt;Enddate = '16May2012'd + 30;&lt;/P&gt;&lt;P&gt;If Startdate &amp;lt; date &amp;lt; Enddate then flag=1;&lt;BR /&gt;else flag = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Mar 2018 22:56:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448532#M283473</guid>
      <dc:creator>arii</dc:creator>
      <dc:date>2018-03-25T22:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 'Class Variable' for Observations in a Specified Time Period.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448534#M283474</link>
      <description>&lt;P&gt;Show us how is your input data. Is the data values are really stored as SAS date values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also use INTNX function here like:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If INTNX("DAY",'15May2012'd,-30)&amp;lt; date &amp;lt; INTNX("DAY",'15May2012'd,30) then flag=1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;else flag = 0;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Mar 2018 23:26:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448534#M283474</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-03-25T23:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 'Class Variable' for Observations in a Specified Time Period.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448536#M283475</link>
      <description>&lt;P&gt;Thank you, SuryaKiran.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See below as requested:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;RSP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/4/1993&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/5/1999&lt;/TD&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11/16/2003&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/7/2005&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3/18/2006&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/11/2007&lt;/TD&gt;&lt;TD&gt;63&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/12/2008&lt;/TD&gt;&lt;TD&gt;92&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5/13/2011&lt;/TD&gt;&lt;TD&gt;56&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/14/2012&lt;/TD&gt;&lt;TD&gt;93&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5/15/2012&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5/16/2012&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5/19/2012&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/20/2012&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;9/21/2013&lt;/TD&gt;&lt;TD&gt;45&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think it has something to do with the way the&lt;STRONG&gt; '+30 days' and '-30 days'&lt;/STRONG&gt; were defined in the codes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your codes are also giving similar outputs as mine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Mar 2018 23:51:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448536#M283475</guid>
      <dc:creator>arii</dc:creator>
      <dc:date>2018-03-25T23:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 'Class Variable' for Observations in a Specified Time Period.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448538#M283476</link>
      <description>&lt;P&gt;What format are your date values? This works fine for me, Check below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
FORMAT Date mmddyy10.;
infile datalines dlm='09'x ;
input Date :mmddyy10.	RSP;
datalines;
1/4/1993	22
2/5/1999	44
11/16/2003	5
1/7/2005	5
3/18/2006	5
1/11/2007	63
2/12/2008	92
5/13/2011	56
1/14/2012	93
5/15/2012	6
5/16/2012	4
5/19/2012	3
6/20/2012	2
9/21/2013	45
;
run;
data want;
Format Start_Date End_Date mmddyy10.;
set have;
Start_Date=INTNX("DAY",'15May2012'd,-30);
End_Date=INTNX("DAY",'15May2012'd,30);
If INTNX("DAY",'15May2012'd,-30)&amp;lt; date &amp;lt; INTNX("DAY",'15May2012'd,30) then flag=1;
else flag = 0;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Mar 2018 00:46:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448538#M283476</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-03-26T00:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 'Class Variable' for Observations in a Specified Time Period.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448583#M283477</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183793"&gt;@arii&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Your code as such looks o.k. to me except that you might also want to include the borders if it's really about +-30 days from a given date.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data xx;
  set x;
  Startdate = '15May2012'd - 30;
  Enddate = '16May2012'd + 30;
  If Startdate &amp;lt;= date &amp;lt;= Enddate then flag=1;
  else flag = 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please post code with sample data which clearly illustrates the issue you're observing?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Mar 2018 09:48:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448583#M283477</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-03-26T09:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 'Class Variable' for Observations in a Specified Time Period.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448855#M283478</link>
      <description>&lt;P&gt;Thank you, Patrick. Your suggestion was helpful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I modified the code a little more to ensure variables in each class are &lt;STRONG&gt;within the specified time period.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made use of:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data xx;&lt;BR /&gt;set x;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Startdate1 = '15May2011'd - 30;&lt;BR /&gt;Enddate1 = '15May2011'd;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Startdate2 = '16May2011'd;&lt;BR /&gt;Enddate2 = '16May2011'd + 30;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If Startdate1 &amp;lt; date &amp;lt; Enddate1 then flag=0;&lt;BR /&gt;If Startdate2 &amp;lt; date &amp;lt; Enddate2 then flag=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This worked fine for me. I'm&amp;nbsp;still learning most of these little manipulations. Thank you for your help once more!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 04:02:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448855#M283478</guid>
      <dc:creator>arii</dc:creator>
      <dc:date>2018-03-27T04:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 'Class Variable' for Observations in a Specified Time Period.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448856#M283479</link>
      <description>&lt;P&gt;Thank you,&amp;nbsp;&lt;SPAN class="login-bold"&gt;Suryakiran. This was helpful too.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 04:03:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Class-Variable-for-Observations-in-a-Specified-Time/m-p/448856#M283479</guid>
      <dc:creator>arii</dc:creator>
      <dc:date>2018-03-27T04:03:18Z</dc:date>
    </item>
  </channel>
</rss>

