<?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: Rollup observations in a DATASTEP in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581906#M165431</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;Have no idea what anyone could find wrong with this approach - MEANS/SUMMARY is designed for that. The only thing I'd change to save my sanity (and also since I'm a lousy typist) is limit the VAR spec to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; var hypertension--skin_ulcer ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And of course, if the real input file is sorted as shown, would use BY instead of CLASS (as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;has suggested) and get rid of NWAY (as in this case it's not needed).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
    <pubDate>Sat, 17 Aug 2019 05:16:51 GMT</pubDate>
    <dc:creator>hashman</dc:creator>
    <dc:date>2019-08-17T05:16:51Z</dc:date>
    <item>
      <title>Rollup observations in a DATASTEP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581756#M165383</link>
      <description>&lt;P&gt;Trying to figure out a way where i can summarize all observations to a unique line corresponding to a distinct YEAR and MEMB_ID. I am able to use a proc summary function to get the needed results but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;123A&lt;/TD&gt;&lt;TD&gt;2018&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123A&lt;/TD&gt;&lt;TD&gt;2019&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123A&lt;/TD&gt;&lt;TD&gt;2019&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My current data step is working but its not catching the Hypertension flag=1 for 2018, not sure why its not finding this observation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TEST123 ;
update INPUT_TEST (obs=0) INPUT_TEST;
by MEMB_ID DATA_YEAR;
run;&lt;/CODE&gt;&lt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t;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I performed another data step summary by renaming the field values and implementing a RETAIN and an IF function. This worked on my small example but found when performed on the over 800k memb_id's it was inserting values of 1 where there were only 0's so it did not work. Still wanted to provide my code.&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 SUMMARY_TEST (keep=MEMB_ID DATA_YEAR HYPERTENSION1 cerebrovasc1 claudication1 &lt;BR /&gt;coronary_artery_disease1 diabetes1 discoloration_lower1 history_of_smoking1 &lt;BR /&gt;myocardial_infrac1 skin_ulcer1 ) ;
set INPUT_TEST; 
by MEMB_ID DATA_YEAR;
length HYPERTENSION1 
cerebrovasc1 
claudication1 
coronary_artery_disease1 
diabetes1 
discoloration_lower1 
history_of_smoking1 
myocardial_infrac1 
skin_ulcer1 8.;
retain HYPERTENSION1 
cerebrovasc1 
claudication1 
coronary_artery_disease1 
diabetes1 
discoloration_lower1 
history_of_smoking1 
myocardial_infrac1 
skin_ulcer1 ;
if HYPERTENSION &amp;gt; 0 then HYPERTENSION1=HYPERTENSION;
if cerebrovasc &amp;gt; 0 then cerebrovasc1=cerebrovasc;
if claudication &amp;gt; 0 then claudication1=claudication;
if coronary_artery_disease &amp;gt; 0 then coronary_artery_disease1=coronary_artery_disease;
if diabetes &amp;gt; 0 then diabetes1=diabetes;
if discoloration_lower &amp;gt; 0 then discoloration_lower1=discoloration_lower;
if history_of_smoking &amp;gt; 0 then history_of_smoking1=history_of_smoking;
if myocardial_infrac &amp;gt; 0 then myocardial_infrac1=myocardial_infrac;
if skin_ulcer &amp;gt; 0 then skin_ulcer1=skin_ulcer;
if last.data_year then output; 
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2019 16:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581756#M165383</guid>
      <dc:creator>bknitch</dc:creator>
      <dc:date>2019-08-16T16:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: Rollup observations in a DATASTEP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581759#M165385</link>
      <description>&lt;P&gt;How big is your data set? Can't see why this would take long time using PROC SUMMARY?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2019 16:13:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581759#M165385</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-08-16T16:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: Rollup observations in a DATASTEP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581765#M165388</link>
      <description>&lt;P&gt;yes I concur with draycut &amp;nbsp;as I feel intrigued to find out what makes proc summary messy. That's rather strange&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyways, here is an array based solution&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input MEMB_ID $	DATA_YEAR	DIABETES	CEREBROVASC	SKIN_ULCER	CORONARY_A_DISEASE	HISTORY_OF_SMOKING	HYPERTENSION	CLAUDICATION	DISCOLORATION_LOWER	MYOCARDIAL_INFRAC;
cards;
123A	2018	0	0	0	0	0	0	0	0	0
123A	2018	0	0	0	0	0	1	0	0	0
123A	2018	1	0	0	0	0	0	0	0	0
123A	2019	0	0	0	0	0	0	0	0	0
123A	2019	0	0	0	0	0	1	0	0	0
;

data _null_;
 set have;
 array t DIABETES--MYOCARDIAL_INFRAC;
 call symputx('n',dim(t));
 stop;
run;

data want;
 do until(last.DATA_YEAR);
  set have;
  by MEMB_ID DATA_YEAR;
  array t DIABETES--MYOCARDIAL_INFRAC;
  array j(&amp;amp;n) _temporary_;
  do over t;
   j(_i_)=j(_i_) max t(_i_);
  end;
 end;
call pokelong(peekclong(addrlong(j(1)),&amp;amp;n*8),addrlong(t(1)),&amp;amp;n*8);
call missing(of j(*));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2019 16:31:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581765#M165388</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-16T16:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: Rollup observations in a DATASTEP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581767#M165390</link>
      <description>&lt;P&gt;I like the idea about using the Update Statement. However, this would work only if the zeros were missing as below. If you can set your zeros to missing, then you're all good &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input MEMB_ID $ DATA_YEAR DIABETES CEREBROVASC SKIN_ULCER 
	  CORONARY_A_DISEASE HISTORY_OF_SMOKING HYPERTENSION CLAUDICATION DISCOLORATION_LOWER MYOCARDIAL_INFRAC;
datalines;
123A 2.18 . . . . . . . . .
123A 2.18 . . . . . 1 . . .
123A 2.18 1 . . . . . . . .
123A 2.19 . . . . . . . . .
123A 2.19 . . . . . 1 . . .
;

data want;
	update have(obs=0) have;
	by MEMB_ID DATA_YEAR;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Aug 2019 16:26:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581767#M165390</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-08-16T16:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: Rollup observations in a DATASTEP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581781#M165395</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;How big is your data set? Can't see why this would take long time using PROC SUMMARY?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Agree.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unless there are unstated requirements this would be my approach:&lt;/P&gt;
&lt;PRE&gt;proc summary data=input_test nway;
   class memb_id data_year;
   var HYPERTENSION cerebrovasc claudication coronary_artery_disease 
         diabetes discoloration_lower history_of_smoking myocardial_infrac 
         skin_ulcer ;
   output out= work.summary (drop=_:) max=;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2019 17:02:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581781#M165395</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-16T17:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: Rollup observations in a DATASTEP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581803#M165406</link>
      <description>&lt;P&gt;This worked just the way i needed it to. Thank you for the insight on dropping the 0's to Null's.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2019 17:57:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581803#M165406</guid>
      <dc:creator>bknitch</dc:creator>
      <dc:date>2019-08-16T17:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Rollup observations in a DATASTEP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581835#M165413</link>
      <description>&lt;P&gt;Note that if the data is already sorted then it is better to use BY instead of CLASS.&amp;nbsp; Then do not have to worry about having more class levels (by groups) than will fit in memory.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2019 19:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581835#M165413</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-16T19:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Rollup observations in a DATASTEP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581906#M165431</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;Have no idea what anyone could find wrong with this approach - MEANS/SUMMARY is designed for that. The only thing I'd change to save my sanity (and also since I'm a lousy typist) is limit the VAR spec to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; var hypertension--skin_ulcer ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And of course, if the real input file is sorted as shown, would use BY instead of CLASS (as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;has suggested) and get rid of NWAY (as in this case it's not needed).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 05:16:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581906#M165431</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-17T05:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Rollup observations in a DATASTEP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581907#M165432</link>
      <description>&lt;P&gt;Anytime, glad you found your answer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 05:27:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581907#M165432</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-08-17T05:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Rollup observations in a DATASTEP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581908#M165433</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;Well, since the data are binary, instead of scanning the array in every record, I'd rather take advantage of the bitwise functions to scan it after each BY group:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                             
  input memb_id $ data_year                             
        diabetes                                        
        cerebrovasc                                     
        skin_ulcer                                      
        coronary_a_disease                              
        history_of_smoking                              
        hypertension                                    
        claudication                                    
        discoloration_lower                             
        myocardial_infrac                               
  ;                                                     
  cards ;                                               
123a 2018 0 0 0 0 0 0 0 0 0                             
123a 2018 0 0 0 0 0 1 0 0 0                             
123a 2018 1 0 0 0 0 0 0 0 0                             
123a 2019 0 0 0 0 0 0 0 0 0                             
123a 2019 0 0 0 0 0 1 0 0 0                             
;                                                       
run ;                                                   
                                                        
data _null_ ;                                           
  set have ;                                            
  array t DIABETES--MYOCARDIAL_INFRAC ;                 
  call symputx ('n', dim (t)) ;                         
  stop ;                                                
run ;                                                   
                                                        
data want (drop = _:) ;                                 
  do _b = 0 by 0 until (last.data_year) ;               
    set have ;                                          
    by memb_id data_year ;                              
    array vv diabetes -- myocardial_infrac ;            
    _b = BOR (_b, input (cats (of vv[*]), binary&amp;amp;n..)) ;
  end ;                                                 
  do over vv ;                                          
    vv = input (char (put (_b, binary&amp;amp;n..), _i_), 1.) ; 
  end ;                                                 
run ;                                                   
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;After all, why not use the bitwise function, albeit rarely, if they are there &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 06:08:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581908#M165433</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-17T06:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: Rollup observations in a DATASTEP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581913#M165434</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Note that if the data is already sorted then it is better to use BY instead of CLASS.&amp;nbsp; Then do not have to worry about having more class levels (by groups) than will fit in memory.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;True if you want the NWAY option from PROC SUMMARY, then if sorted BY will work faster than CLASS. If you want to turn off NWAY, then you have to use CLASS.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 10:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rollup-observations-in-a-DATASTEP/m-p/581913#M165434</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-17T10:48:40Z</dc:date>
    </item>
  </channel>
</rss>

