<?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 new variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Creating-new-variables/m-p/822682#M35023</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set member_data_sample;
    by member_id visit_year;
    delta_days=visit_date-lag(visit_date);
    if first.visit_year then do;
        delta_days=.;
        counter=0;
    end;
    counter+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 11 Jul 2022 21:14:44 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-07-11T21:14:44Z</dc:date>
    <item>
      <title>Creating new variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-new-variables/m-p/822679#M35022</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;I am trying to create a new variable for days between just the first visit and the second visit in each year. Also I am trying to create another variable for number of visit for each year. Could you please help me for this issue because I am struggling. Here is a sample of the dataset. Thank you for your time and your help in advance.&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;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data Member_Data_Sample;
input VISIT_DATE :date9. MEMBER_ID $ VISIT_YEAR VISIT_STATUS;
format  VISIT_DATE :date9.;
datalines;
06NOV2013 AA10450Z 2013 0 
05JUN2014 AA10450Z 2014 1 
26JUN2014 AA10450Z 2014 1 
21AUG2014 AA10450Z 2014 1 
18SEP2014 AA10450Z 2014 1 
03DEC2014 AA10450Z 2014 1 
11MAR2015 AA10450Z 2015 1 
15APR2015 AA10450Z 2015 1 
07OCT2015 AA10450Z 2015 1 
13OCT2015 AA10450Z 2015 1 
26OCT2015 AA10450Z 2015 1 
09NOV2015 AA10450Z 2015 1 
07DEC2015 AA10450Z 2015 1 
21DEC2015 AA10450Z 2015 1 
19APR2017 AA10450Z 2017 1 
10SEP2018 AA10450Z 2018 0 
15APR2019 AA10450Z 2019 1 
;
run;&lt;/PRE&gt;&lt;P&gt;data Member_Data_Sample;&lt;BR /&gt;input VISIT_DATE :date9. MEMBER_ID $ VISIT_YEAR VISIT_STATUS;&lt;BR /&gt;format VISIT_DATE :date9.;&lt;BR /&gt;datalines;&lt;BR /&gt;06NOV2013 AA10450Z 2013 0&lt;BR /&gt;05JUN2014 AA10450Z 2014 1&lt;BR /&gt;26JUN2014 AA10450Z 2014 1&lt;BR /&gt;21AUG2014 AA10450Z 2014 1&lt;BR /&gt;18SEP2014 AA10450Z 2014 1&lt;BR /&gt;03DEC2014 AA10450Z 2014 1&lt;BR /&gt;11MAR2015 AA10450Z 2015 1&lt;BR /&gt;15APR2015 AA10450Z 2015 1&lt;BR /&gt;07OCT2015 AA10450Z 2015 1&lt;BR /&gt;13OCT2015 AA10450Z 2015 1&lt;BR /&gt;26OCT2015 AA10450Z 2015 1&lt;BR /&gt;09NOV2015 AA10450Z 2015 1&lt;BR /&gt;07DEC2015 AA10450Z 2015 1&lt;BR /&gt;21DEC2015 AA10450Z 2015 1&lt;BR /&gt;19APR2017 AA10450Z 2017 1&lt;BR /&gt;10SEP2018 AA10450Z 2018 0&lt;BR /&gt;15APR2019 AA10450Z 2019 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 21:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-new-variables/m-p/822679#M35022</guid>
      <dc:creator>OJohn_StaT</dc:creator>
      <dc:date>2022-07-11T21:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-new-variables/m-p/822682#M35023</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set member_data_sample;
    by member_id visit_year;
    delta_days=visit_date-lag(visit_date);
    if first.visit_year then do;
        delta_days=.;
        counter=0;
    end;
    counter+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jul 2022 21:14:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-new-variables/m-p/822682#M35023</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-11T21:14:44Z</dc:date>
    </item>
  </channel>
</rss>

