<?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 do I get a value to repeat itself in the subsequent rows for the same subject after merging? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-a-value-to-repeat-itself-in-the-subsequent-rows-for/m-p/830905#M328341</link>
    <description>&lt;P&gt;I'm confused. You're asking about merging, but you only show one dataset.&amp;nbsp; Suggest you show a small example of both datasets you are merging, and the code you used to merge them.&amp;nbsp; Then you can also show the output you get from merging them, and describe why you are unhappy with that output.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Aug 2022 15:30:14 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2022-08-29T15:30:14Z</dc:date>
    <item>
      <title>How do I get a value to repeat itself in the subsequent rows for the same subject after merging?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-a-value-to-repeat-itself-in-the-subsequent-rows-for/m-p/830904#M328340</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I merged a data set with another data set by subject. The one data set includes the variables arm, and armn, but the other one just includes subjects. I would like to have it so that the newly merged data set contains the same values for arm and armn after the merge for each subject.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;edit: in case there is confusion, the data set that is presented below is the merged data set. I'm trying to get repeat values of arm and armn for each subject so that the final data set looks like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;001, a, 1&lt;/P&gt;
&lt;P&gt;001, a, 1&lt;/P&gt;
&lt;P&gt;002, b, 2&lt;/P&gt;
&lt;P&gt;002, b, 2&lt;/P&gt;
&lt;P&gt;002, b, 2&lt;/P&gt;
&lt;P&gt;003, c, 3&lt;/P&gt;
&lt;P&gt;003, c, 3&lt;/P&gt;
&lt;P&gt;003, c, 3&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
infile datalines dsd dlm=",";
	input subject $ arm $ armn;
datalines;
001, a, 1
001, , ,
002, b, 2
002, b, 2
002, , 
003, c, 3
003, , 
003, , 
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 15:39:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-a-value-to-repeat-itself-in-the-subsequent-rows-for/m-p/830904#M328340</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2022-08-29T15:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get a value to repeat itself in the subsequent rows for the same subject after merging?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-a-value-to-repeat-itself-in-the-subsequent-rows-for/m-p/830905#M328341</link>
      <description>&lt;P&gt;I'm confused. You're asking about merging, but you only show one dataset.&amp;nbsp; Suggest you show a small example of both datasets you are merging, and the code you used to merge them.&amp;nbsp; Then you can also show the output you get from merging them, and describe why you are unhappy with that output.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 15:30:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-a-value-to-repeat-itself-in-the-subsequent-rows-for/m-p/830905#M328341</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-08-29T15:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get a value to repeat itself in the subsequent rows for the same subject after merging?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-a-value-to-repeat-itself-in-the-subsequent-rows-for/m-p/830908#M328343</link>
      <description>Hi Quentin, the data set that is presented is the new data set after the merge. I would like to know how I can repeat the values for arm and armn for each subject bc after the merged happened, the data set that did not include those variables were displayed as missing.</description>
      <pubDate>Mon, 29 Aug 2022 15:37:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-a-value-to-repeat-itself-in-the-subsequent-rows-for/m-p/830908#M328343</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2022-08-29T15:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get a value to repeat itself in the subsequent rows for the same subject after merging?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-a-value-to-repeat-itself-in-the-subsequent-rows-for/m-p/830916#M328344</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/252358"&gt;@Hello_there&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi Quentin, the data set that is presented is the new data set after the merge. I would like to know how I can repeat the values for arm and armn for each subject bc after the merged happened, the data set that did not include those variables were displayed as missing.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then most likely you made the mistake of have the variables on BOTH of the input datasets.&amp;nbsp; The variables you want replicated should only appear on the dataset that has just the one observation per BY group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you have your subject level dataset with ARM and&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data subjects;
  input subject $ arm $ armn;
datalines;
001 a 1
002 b 2
003 c 3
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And your dataset that has repeated measure per subject.&amp;nbsp; So perhaps heart rate measure at different visits.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data visits;
  input subject $ visit hr ;
datalines;
001 1 65
001 2 70
002 1 80
002 2 75 
003 1 72
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can merge by SUBJECT and the values of ARM and ARMN will be retained onto every observation (that is in the SUBJECTS dataset).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge subjects visits;
  by subject;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;Obs    subject    arm    armn    visit    hr

 1       001       a       1       1      65
 2       001       a       1       2      70
 3       002       b       2       1      80
 4       002       b       2       2      75
 5       003       c       3       1      72


&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 15:53:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-a-value-to-repeat-itself-in-the-subsequent-rows-for/m-p/830916#M328344</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-08-29T15:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get a value to repeat itself in the subsequent rows for the same subject after merging?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-a-value-to-repeat-itself-in-the-subsequent-rows-for/m-p/830983#M328366</link>
      <description>Thanks for taking time to help, Tom!</description>
      <pubDate>Mon, 29 Aug 2022 19:23:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-a-value-to-repeat-itself-in-the-subsequent-rows-for/m-p/830983#M328366</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2022-08-29T19:23:53Z</dc:date>
    </item>
  </channel>
</rss>

