<?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: How to make an snapshot of a date for each respondent in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-an-snapshot-of-a-date-for-each-respondent/m-p/698446#M213611</link>
    <description>&lt;P&gt;Another way creating one record per "flagged year";&lt;/P&gt;
&lt;PRE&gt;data have;
  input student  start_date :date9. end_date :date9.;
  format start_date end_date date9.;
datalines;
1  04Sep1993 26jun1995
2  22Nov2002 20May2005
;

data want;
   set have;
   do d = start_date to end_date;
         d= intnx('year',d,0,'e');
         flagyear = year(d);
         if d le end_date then output;
         d=d+1;
   end;
   drop d;
run;&lt;/PRE&gt;</description>
    <pubDate>Thu, 12 Nov 2020 17:14:52 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-11-12T17:14:52Z</dc:date>
    <item>
      <title>How to make an snapshot of a date for each respondent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-an-snapshot-of-a-date-for-each-respondent/m-p/698423#M213598</link>
      <description>&lt;P&gt;Hi everybody,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset of students in a high school. The data includes the start-date and end-date for each student. I would like to make an snapshot of a date, e.g. 31 december of each year, and find out if the respondent attended in the high school on that date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;student&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; start_date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; end_date&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 04 Sept, 1993&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 26 june, 1995&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22 Nov, 2002&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20 May, 2005&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;I would like to make a variable which is if the student 1 attended the high school at 31 december of each year between 1993 to 1995, then the value of the new variable is 1 otherwise 0, and the same for each pther student.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 16:06:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-an-snapshot-of-a-date-for-each-respondent/m-p/698423#M213598</guid>
      <dc:creator>mandan414</dc:creator>
      <dc:date>2020-11-12T16:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to make an snapshot of a date for each respondent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-an-snapshot-of-a-date-for-each-respondent/m-p/698427#M213601</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274426"&gt;@mandan414&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;student&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; start_date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; end_date&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 04 Sept, 1993&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 26 june, 1995&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22 Nov, 2002&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20 May, 2005&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are these true numeric variables that are SAS date values, formatted? Or are they text strings?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 16:08:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-an-snapshot-of-a-date-for-each-respondent/m-p/698427#M213601</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-11-12T16:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to make an snapshot of a date for each respondent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-an-snapshot-of-a-date-for-each-respondent/m-p/698430#M213603</link>
      <description>&lt;P&gt;They are the true values of the SAS, numeric, date ......&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 16:13:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-an-snapshot-of-a-date-for-each-respondent/m-p/698430#M213603</guid>
      <dc:creator>mandan414</dc:creator>
      <dc:date>2020-11-12T16:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to make an snapshot of a date for each respondent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-an-snapshot-of-a-date-for-each-respondent/m-p/698432#M213604</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274426"&gt;@mandan414&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;They are the true values of the SAS, numeric, date ......&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In your DATA step use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;flag1993 = (start_date&amp;lt;='31DEC1993'd&amp;lt;=end_date);
flag1994 = (start_date&amp;lt;='31DEC1994'd&amp;lt;=end_date);&lt;BR /&gt;/* etc.&amp;nbsp;*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 16:16:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-an-snapshot-of-a-date-for-each-respondent/m-p/698432#M213604</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-11-12T16:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to make an snapshot of a date for each respondent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-an-snapshot-of-a-date-for-each-respondent/m-p/698435#M213606</link>
      <description>&lt;P&gt;That is great, but it will be very long since the dataset covers almost 50 years. I think I need to go with Do statement, but I'm not good at that. Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 16:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-an-snapshot-of-a-date-for-each-respondent/m-p/698435#M213606</guid>
      <dc:creator>mandan414</dc:creator>
      <dc:date>2020-11-12T16:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to make an snapshot of a date for each respondent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-an-snapshot-of-a-date-for-each-respondent/m-p/698439#M213608</link>
      <description>&lt;P&gt;If you mean that you want to take the two lines I showed for 1993 and 1994, and you want similar for all years (for example) 1950 to 2000, then this is how you do it.&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 flag flag1950-flag2000;
    year=1950;
    do i=1 to dim(yr);
        flag(i)=(start_date&amp;lt;=mdy(12,31,year)&amp;lt;=end_date);
        year=year+1;
    end;
    drop i year;
run;
         &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 16:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-an-snapshot-of-a-date-for-each-respondent/m-p/698439#M213608</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-11-12T16:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to make an snapshot of a date for each respondent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-an-snapshot-of-a-date-for-each-respondent/m-p/698446#M213611</link>
      <description>&lt;P&gt;Another way creating one record per "flagged year";&lt;/P&gt;
&lt;PRE&gt;data have;
  input student  start_date :date9. end_date :date9.;
  format start_date end_date date9.;
datalines;
1  04Sep1993 26jun1995
2  22Nov2002 20May2005
;

data want;
   set have;
   do d = start_date to end_date;
         d= intnx('year',d,0,'e');
         flagyear = year(d);
         if d le end_date then output;
         d=d+1;
   end;
   drop d;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Nov 2020 17:14:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-an-snapshot-of-a-date-for-each-respondent/m-p/698446#M213611</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-12T17:14:52Z</dc:date>
    </item>
  </channel>
</rss>

