<?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 copy a number in a variable through all other IDs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-number-in-a-variable-through-all-other-IDs/m-p/533701#M146353</link>
    <description>This works!!&lt;BR /&gt;Thank you for the answer and advice!</description>
    <pubDate>Thu, 07 Feb 2019 19:32:58 GMT</pubDate>
    <dc:creator>A_Halps</dc:creator>
    <dc:date>2019-02-07T19:32:58Z</dc:date>
    <item>
      <title>How to copy a number in a variable through all other IDs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-number-in-a-variable-through-all-other-IDs/m-p/533688#M146348</link>
      <description>&lt;P&gt;If the first row for colon_res_bill=1, then I want all of the other colon_res_bill's for that study_id to also be 1.&lt;BR /&gt;How would I go about this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have tried, but it is not working.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=colon_auth_paid	out=colon_auth_paid_sort;
	by study_id descending colon_res_bill;
run;

data colon_paid_heirarchy1;
	set colon_auth_paid_sort;
	by study_id descending colon_res_bill;
		if first.colon_res_bill=1 then colon_res_bill_final=1;
		else colon_res_bill_final=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="colon res bill.png" style="width: 305px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26950i9C779D7F40EC6F76/image-size/large?v=v2&amp;amp;px=999" role="button" title="colon res bill.png" alt="colon res bill.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 19:29:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-number-in-a-variable-through-all-other-IDs/m-p/533688#M146348</guid>
      <dc:creator>A_Halps</dc:creator>
      <dc:date>2019-02-07T19:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy a number in a variable through all other IDs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-number-in-a-variable-through-all-other-IDs/m-p/533697#M146351</link>
      <description>&lt;P&gt;In the future, please include data as SAS data step code. Do NOT include data as a screen capture.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This solution assumes the data set is properly sorted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    retain flag;
    set have;
    by study_id;
    if first.study_id then flag=(colon_res_bill=1);
    if flag=1 then colon_res_bill=1;
    drop flag;
run;
&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, 07 Feb 2019 19:30:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-number-in-a-variable-through-all-other-IDs/m-p/533697#M146351</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-02-07T19:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy a number in a variable through all other IDs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-number-in-a-variable-through-all-other-IDs/m-p/533699#M146352</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A id="link_8" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212048" target="_self"&gt;&lt;SPAN class=""&gt;A_Halps&lt;/SPAN&gt;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;This can be achieved with the &lt;A href="https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lrcon&amp;amp;docsetTarget=p0tq11jtmrhsd4n1co4p5tu1fbsi.htm&amp;amp;locale=en" target="_self"&gt;FIRST. &amp;amp; LAST. processing&lt;/A&gt; and the &lt;A href="https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p0t2ac0tfzcgbjn112mu96hkgg9o.htm&amp;amp;locale=en" target="_self"&gt;retain statement&amp;nbsp;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Here's an example&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data input ;
 	drop i ;
	do study_id=1 to 3 ;
		do i=1 to 5 ;
			if i=1 and ranuni(1)&amp;gt;0.5 then
				colon_res_bill=1 ;
			else
				colon_res_bill=0 ;
			output ;
		end ;
	end ;
run ;

proc sort data=input out=srtd ;
	by study_id ;
run ;

data results ;
	retain retain_crb 0 ;
	drop retain_crb ;
	set srtd ;
	by study_id ;
	if first.study_id then
		retain_crb=colon_res_bill ;
	if retain_crb=1 then
		colon_res_bill=1 ;
	output ;
	if last.study_id then	
		retain_crb=0 ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Feb 2019 19:30:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-number-in-a-variable-through-all-other-IDs/m-p/533699#M146352</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2019-02-07T19:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy a number in a variable through all other IDs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-number-in-a-variable-through-all-other-IDs/m-p/533701#M146353</link>
      <description>This works!!&lt;BR /&gt;Thank you for the answer and advice!</description>
      <pubDate>Thu, 07 Feb 2019 19:32:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-number-in-a-variable-through-all-other-IDs/m-p/533701#M146353</guid>
      <dc:creator>A_Halps</dc:creator>
      <dc:date>2019-02-07T19:32:58Z</dc:date>
    </item>
  </channel>
</rss>

