<?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: Making dummy values continue into subsequent observations in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263162#M57709</link>
    <description>&lt;P&gt;A slight variation on &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt;'s logic:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro checkvar(variable);
retain old&amp;amp;variable;
if not first.patientid and old&amp;amp;variable ne '' then &amp;amp;variable = old&amp;amp;variable;
old&amp;amp;variable = &amp;amp;variable;
drop old&amp;amp;variable;
%mend;

data patients2;
set patients;
by patientid;
%checkvar(diaga);
%checkvar(diagb);
%checkvar(diagc);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 12 Apr 2016 12:42:43 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-04-12T12:42:43Z</dc:date>
    <item>
      <title>Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263144#M57706</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with records of patients and their diagnoses. Here is a simplified version:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;CODE class=" language-sas"&gt;data patients ;
infile datalines dsd delimiter=' '; 
input patientID $ year $ diagA $ diagB $ diagC $ ;
datalines;
1 2010 . . .
1 2011 . 1 .
1 2012 . . 1
1 2014 . . .
2 2009 1 . .
2 2010 1 . .
2 2013 . 1 .
2 2015 . . .
;
run;&lt;/CODE&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;What code can I use to make sure that once a patient has received a diagnosis, a value of 1 is inserted under that variable for each subsequent observation? To illustrate, I want this:&lt;/FONT&gt;&lt;/FONT&gt;&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;&lt;CODE class=" language-sas"&gt;data patients2 ;
infile datalines dsd delimiter=' '; 
input patientID $ year $ diagA $ diagB $ diagC $ ;
datalines;
1 2010 . . .
1 2011 . 1 .
1 2012 . 1 1
1 2014 . 1 1
2 2009 1 . .
2 2010 1 . .
2 2013 . 1 .
2 2015 1 1 .
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Apr 2016 11:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263144#M57706</guid>
      <dc:creator>udden2903</dc:creator>
      <dc:date>2016-04-12T11:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263152#M57707</link>
      <description>&lt;P&gt;Bit verbose, am on a meeting so cant think properly:&lt;/P&gt;
&lt;PRE&gt;data want (drop=lstdiag:);&lt;BR /&gt; set patients;&lt;BR /&gt; retain lstdiaga lstdiagb lstdiagc;&lt;BR /&gt; if diaga ne "" then lstdiaga=diaga;&lt;BR /&gt; if diagb ne "" then lstdiagb=diagb;&lt;BR /&gt; if diagc ne "" then lstdiagc=diagc; &lt;BR /&gt; diaga=coalescec(diaga,lstdiaga);&lt;BR /&gt; diagb=coalescec(diagb,lstdiagb);&lt;BR /&gt; diagc=coalescec(diagc,lstdiagc);&lt;BR /&gt;run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Apr 2016 12:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263152#M57707</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-12T12:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263162#M57709</link>
      <description>&lt;P&gt;A slight variation on &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt;'s logic:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro checkvar(variable);
retain old&amp;amp;variable;
if not first.patientid and old&amp;amp;variable ne '' then &amp;amp;variable = old&amp;amp;variable;
old&amp;amp;variable = &amp;amp;variable;
drop old&amp;amp;variable;
%mend;

data patients2;
set patients;
by patientid;
%checkvar(diaga);
%checkvar(diagb);
%checkvar(diagc);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Apr 2016 12:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263162#M57709</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-04-12T12:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263164#M57710</link>
      <description>&lt;P&gt;Your want doesn't look right to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data patients; 
   input patientID $ year $ diagA $ diagB $ diagC $; 
   datalines; 
1 2010 . . . 
1 2011 . 1 . 
1 2012 . . 1 
1 2014 . . . 
2 2009 1 . . 
2 2010 1 . . 
2 2013 . 1 . 
2 2015 . . . 
;;;; 
   run;
data patients;
   update patients(obs=0) patients;
   by patientid;
   output;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2694iB9D4DDBA6445E39D/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 12:44:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263164#M57710</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-04-12T12:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263169#M57711</link>
      <description>&lt;P&gt;Creative! Like it, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__﻿&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 12:57:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263169#M57711</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-04-12T12:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263170#M57712</link>
      <description>Thank you for your help, I can see the logic in your code. The problem is that I have more than 10 diagnosis variables, and I am reluctant to write one line of code for each one of them. Do you know if there's any way of working with arrays to get around this?</description>
      <pubDate>Tue, 12 Apr 2016 13:05:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263170#M57712</guid>
      <dc:creator>udden2903</dc:creator>
      <dc:date>2016-04-12T13:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263172#M57713</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/73651"&gt;@udden2903&lt;/a&gt; wrote:&lt;BR /&gt;Thank you for your help, I can see the logic in your code. The problem is that I have more than 10 diagnosis variables, and I am reluctant to write one line of code for each one of them. Do you know if there's any way of working with arrays to get around this?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;'s code will take care of that quite nicely, as it lets SAS do it automatically.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 13:14:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263172#M57713</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-04-12T13:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263173#M57714</link>
      <description>Is there a way of using the retain statement with an array statement to solve my problem? I have more than 10 diagnoses in my original dataset and I would like to make the code as efficient as possible by invoking something like an array statement.</description>
      <pubDate>Tue, 12 Apr 2016 13:18:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263173#M57714</guid>
      <dc:creator>udden2903</dc:creator>
      <dc:date>2016-04-12T13:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263174#M57715</link>
      <description>&lt;P&gt;Why do you have more than 10 diagnosis variables? &amp;nbsp;If you normalise your data you will find programming is far easier:&lt;/P&gt;
&lt;P&gt;PatientId &amp;nbsp; &amp;nbsp;Diag_No &amp;nbsp; &amp;nbsp;Diag&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xyz&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; zyf&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do it with arrays of course, but it just makes programming more tricky:&lt;/P&gt;
&lt;PRE&gt;%let elements=3;

data patients ; 
  infile datalines dsd delimiter=' '; 
  input patientID $ year $ diagA $ diagB $ diagC $ ; 
datalines; 
1 2010 . . . 
1 2011 . 1 . 
1 2012 . . 1 
1 2014 . . . 
2 2009 1 . . 
2 2010 1 . . 
2 2013 . 1 . 
2 2015 . . . 
; 
run;

data want (drop=i ret:);
  set patients;
  array ret{&amp;amp;elements.} $3;
  array act{&amp;amp;elements.} diag:;
  retain ret:;
  do i=1 to &amp;amp;elements.;
    if act{i} ne "" then ret{i}=act{i};
    act{i}=coalescec(act{i},ret{i});
  end;
run;  &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 13:20:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263174#M57715</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-12T13:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263177#M57716</link>
      <description>A patient can have many different combinations of diagnoses over time. Concatenating the diagnosis dummy variables into one single variable will not be helpful as I want to know, for each observation, all of the diagnoses the patient has had up until that point. I think I would miss that with your solution...</description>
      <pubDate>Tue, 12 Apr 2016 13:27:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263177#M57716</guid>
      <dc:creator>udden2903</dc:creator>
      <dc:date>2016-04-12T13:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263182#M57717</link>
      <description>&lt;P&gt;This version of the update method unsures that only variables of interest "DIAG:" are carried forward.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data patients; 
   input patientID $ year $ diagA $ diagB $ diagC $; 
   datalines; 
1 2010 . . . 
1 2011 . 1 . 
1 2012 . . 1 
1 2014 . . . 
2 2009 1 . . 
2 2010 1 . . 
2 2013 . 1 . 
2 2015 . . . 
;;;; 
   run;
%let locf=patientid diag:;
data patients;
   if 0 then set patients;
   update patients(obs=0 keep=&amp;amp;locf) patients(keep=&amp;amp;locf);
   by patientid;
   set patients(drop=&amp;amp;locf);
   output;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 13:38:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263182#M57717</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-04-12T13:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263183#M57718</link>
      <description>&lt;P&gt;No, you can do any processing you can do with tranposed data with normalised data. &amp;nbsp;The only difference is you don't need to know how many observations up front as the structure does not change, only the amount of data to process. &amp;nbsp;With transposed data, the strcuture changes with more or fewer data elements, making programming more difficult.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 13:36:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263183#M57718</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-12T13:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263192#M57719</link>
      <description>&lt;P&gt;I can't get this code to work. In my actual dataset, the diagnoses have names like "L40" and "K50", so I would have to change this part of your code:&lt;BR /&gt;&lt;BR /&gt;%let locf=patientid diag:;&lt;BR /&gt;&lt;BR /&gt;I tested it for the L40 diagnosis, using (%let locf=patientid L:; ), but it still does not work.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 13:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263192#M57719</guid>
      <dc:creator>udden2903</dc:creator>
      <dc:date>2016-04-12T13:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263201#M57720</link>
      <description>&lt;P&gt;You need to mention all relevant details when your post. &amp;nbsp;If your names are not DIAG: as you implied then obviously DIAG: will not work for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you were to define an array of the diagnosis variables&amp;nbsp;then how would you do that?&lt;/P&gt;
&lt;P&gt;Would you use a name range list? &amp;nbsp;You can always list the individual names. &amp;nbsp;Or use some combination of "SAS Variable Lists" and names etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to learn about the "SAS Variable List". &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 14:22:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263201#M57720</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-04-12T14:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263202#M57721</link>
      <description>I got it to work now! Thanks for your help!</description>
      <pubDate>Tue, 12 Apr 2016 14:25:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263202#M57721</guid>
      <dc:creator>udden2903</dc:creator>
      <dc:date>2016-04-12T14:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263382#M57740</link>
      <description>&lt;P&gt;Be careful. John King's code would work only if year&amp;nbsp;don't have any missing value .&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 02:55:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263382#M57740</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-13T02:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263478#M57743</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Be careful. John King's code would work only if year&amp;nbsp;don't have any missing value .&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;apparently you didn't read the whole thread. &amp;nbsp;You don't know what you're talking about.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 11:36:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263478#M57743</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-04-13T11:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263760#M57750</link>
      <description>&lt;P&gt;I implemented your code, replacing diag: with K: L: M:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are right, I shouldn't have named my diagnosis variables DiagA, DiagB and DiagC. I was simply trying to make the problem more straightforward to the viewer, but I will avoid making such changes in the future.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you mind quickly explaining what your code does? I'm new to macros and I think gaining some understanding of your code would be helpful as I start learning more about them.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 05:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263760#M57750</guid>
      <dc:creator>udden2903</dc:creator>
      <dc:date>2016-04-14T05:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263838#M57751</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/73651"&gt;@udden2903&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would you mind quickly explaining what your code does? I'm new to macros and I think gaining some understanding of your code would be helpful as I start learning more about them.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1 %let locf=patientid diag:;
2 data patients;
3   if 0 then set patients;
4   update patients(obs=0 keep=&amp;amp;locf) patients(keep=&amp;amp;locf);
5   by patientid;
6   set patients(drop=&amp;amp;locf);
7   output;
8   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;OL&gt;
&lt;LI&gt;define the list of variables and KEY(S) to be LOCFed so we only have to type it once.&lt;/LI&gt;
&lt;LI&gt;create a new data set (same name as old)&lt;/LI&gt;
&lt;LI&gt;preserve order of variables in the new data set using the old&lt;/LI&gt;
&lt;LI&gt;update patients zeros obs with itself&amp;nbsp;as transaction file (using missingcheck feature of update to LOCF)&lt;/LI&gt;
&lt;LI&gt;update requires a by statement and this resets the LOCF at the start of each PATIENTID.&lt;/LI&gt;
&lt;LI&gt;Bring in the variable we don't want LOCFed.&lt;/LI&gt;
&lt;LI&gt;output needed because UPDATE outputs on LAST.(by-var) by default.&lt;/LI&gt;
&lt;LI&gt;run&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;There is really no MACRO here just the macro variable (symbolic variable) LOCF&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 12:32:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/263838#M57751</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-04-14T12:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: Making dummy values continue into subsequent observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/269650#M58168</link>
      <description>&lt;P&gt;How would you modify this code to make sure that the dummy values from the previous observation continue into the current observation ONLY if the current observation has missing values for ALL of the dummy variables? Right now, the value of a dummy variable is carried forward as long as the value of that variable is missing in the next observation, without any consideration of the values of the other dummy variables.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 07:11:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Making-dummy-values-continue-into-subsequent-observations/m-p/269650#M58168</guid>
      <dc:creator>udden2903</dc:creator>
      <dc:date>2016-05-11T07:11:59Z</dc:date>
    </item>
  </channel>
</rss>

