<?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: recode just the multiples of 4 of a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/553419#M153901</link>
    <description>&lt;P&gt;I have a follow-up question regarding this topic - if I want to find the frequent user counting those with 4 visits at the ED in 365 days after each visit instead of 4 visits in a calendar year only, how should I do code it?&lt;/P&gt;</description>
    <pubDate>Tue, 23 Apr 2019 20:42:58 GMT</pubDate>
    <dc:creator>tomas-andriotti</dc:creator>
    <dc:date>2019-04-23T20:42:58Z</dc:date>
    <item>
      <title>recode just the multiples of 4 of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/539917#M148880</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I am trying to recode a variable defined as freq_user in a long data set (longitudinal form). Frequent users (freq_users) were identified as those who went to the emergent department (ED) more often than 4 times a year. It turns out that all observations in a year (visits to ED) were identified as freq_users if the individual has gone more than 4 times to ED - the 1st, 2nd and&amp;nbsp;3rd as well as the 4th visit. However, I just need to identify as freq_users those observations at the 4th visit or&amp;nbsp;its multiples (8th, 12th and so on) if they were considered so.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Look forward to hearing from you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tomas&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 18:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/539917#M148880</guid>
      <dc:creator>tomas-andriotti</dc:creator>
      <dc:date>2019-03-03T18:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: recode just the multiples of 4 of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/539922#M148881</link>
      <description>&lt;P&gt;Some key questions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are the names of your variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does your data set contain a variable holding the YEAR?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you trust the flags that were already set up?&amp;nbsp; For example, if a person has 5 ER visits one year, and 2 the next, are you certain that the 2 visits in the next year are not being flagged?&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 18:33:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/539922#M148881</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-03-03T18:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: recode just the multiples of 4 of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/539923#M148882</link>
      <description>&lt;P&gt;Ansewers&amp;nbsp;to your questions&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. the name of the variables are :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Id: individuals&lt;/P&gt;&lt;P&gt;k: observations&amp;nbsp;or visits&lt;/P&gt;&lt;P&gt;begdate&amp;nbsp;: date of the observations - visit to&amp;nbsp;the ED&lt;/P&gt;&lt;P&gt;fy&amp;nbsp;: fiscal year (sep year X - august&amp;nbsp;year X+1)&lt;/P&gt;&lt;P&gt;freq_user_fy : 4 visits or more to the ED a year&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. yes, the dataset contains fy = fiscal year that was used to code freq users within a fiscal year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. I am certain that if the next 2 visits happen in another fiscal year that they were not flagged but if they happened within the fiscal year, all of them were flagged, which is the issue I am trying to solve because I need just the 4th visit to ED within the same fiscal year&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 18:53:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/539923#M148882</guid>
      <dc:creator>tomas-andriotti</dc:creator>
      <dc:date>2019-03-03T18:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: recode just the multiples of 4 of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/539925#M148883</link>
      <description>&lt;P&gt;OK, here's an approach you can use then:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
   by id fy begdate;
run;

data want;
   set have;
   by id fy;
   if first.fy then counter = 1;
   else counter + 1;
   drop counter;
   new_freq_user_fy = (mod(counter, 4) = 0);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This actually counts within the fiscal year.&amp;nbsp; If you want to count within the calendar year, it's just mildly more complex.&amp;nbsp; It would require creating a YEAR variable based on the BEGDATE and using that YEAR variable instead of FY.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 19:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/539925#M148883</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-03-03T19:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: recode just the multiples of 4 of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/540163#M148963</link>
      <description>&lt;P&gt;thank you !this worked!&lt;BR /&gt;so if I want to count within a calendar year, does the code below just changing fy to year (after creating the calendar year ) suffice?&amp;nbsp;&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;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;sort&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt; year begdate&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; want&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt; year&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;first&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.year&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; counter &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token keyword"&gt;else&lt;/SPAN&gt; counter &lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token keyword"&gt;drop&lt;/SPAN&gt; counter&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   new_freq_user_y &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;mod&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;counter&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;4&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&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;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 19:15:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/540163#M148963</guid>
      <dc:creator>tomas-andriotti</dc:creator>
      <dc:date>2019-03-04T19:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: recode just the multiples of 4 of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/540168#M148966</link>
      <description>&lt;P&gt;Yes, given that you first create YEAR holding the calendar year, that's exactly the right follow-up step.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 19:21:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/540168#M148966</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-03-04T19:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: recode just the multiples of 4 of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/553419#M153901</link>
      <description>&lt;P&gt;I have a follow-up question regarding this topic - if I want to find the frequent user counting those with 4 visits at the ED in 365 days after each visit instead of 4 visits in a calendar year only, how should I do code it?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 20:42:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/553419#M153901</guid>
      <dc:creator>tomas-andriotti</dc:creator>
      <dc:date>2019-04-23T20:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: recode just the multiples of 4 of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/553505#M153934</link>
      <description>&lt;P&gt;That would require a different approach.&amp;nbsp; PROC SQL would be a good tool for the job, but is a topic where my skills are just average.&amp;nbsp; If you really need that, I suggest you post it as a separate question.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2019 02:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-just-the-multiples-of-4-of-a-variable/m-p/553505#M153934</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-24T02:54:17Z</dc:date>
    </item>
  </channel>
</rss>

