<?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 Creating new variable assigned as an existing variable by conditions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-variable-assigned-as-an-existing-variable-by/m-p/848725#M335540</link>
    <description>&lt;P&gt;Hello! I'm attempting to create a new variable that assigns the mean in period 2 to period 1 for each group. Better to explain with the data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;
input group period mean;
datalines;
1 1 10
1 2 20
2 1 33
2 2 22
3 1 21
3 2 34
4 1 33
4 2 32
;
run;&lt;/PRE&gt;&lt;P&gt;This is what I want:&lt;/P&gt;&lt;PRE&gt;data want;
input group period mean meanp2;
datalines;
1 1 10 20 
1 2 20 20
2 1 33 22
2 2 22 22
3 1 21 34
3 2 34 34
4 1 33 32
4 2 32 32
;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Dec 2022 14:43:01 GMT</pubDate>
    <dc:creator>ldavis020</dc:creator>
    <dc:date>2022-12-09T14:43:01Z</dc:date>
    <item>
      <title>Creating new variable assigned as an existing variable by conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-variable-assigned-as-an-existing-variable-by/m-p/848725#M335540</link>
      <description>&lt;P&gt;Hello! I'm attempting to create a new variable that assigns the mean in period 2 to period 1 for each group. Better to explain with the data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;
input group period mean;
datalines;
1 1 10
1 2 20
2 1 33
2 2 22
3 1 21
3 2 34
4 1 33
4 2 32
;
run;&lt;/PRE&gt;&lt;P&gt;This is what I want:&lt;/P&gt;&lt;PRE&gt;data want;
input group period mean meanp2;
datalines;
1 1 10 20 
1 2 20 20
2 1 33 22
2 2 22 22
3 1 21 34
3 2 34 34
4 1 33 32
4 2 32 32
;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2022 14:43:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-variable-assigned-as-an-existing-variable-by/m-p/848725#M335540</guid>
      <dc:creator>ldavis020</dc:creator>
      <dc:date>2022-12-09T14:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable assigned as an existing variable by conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-variable-assigned-as-an-existing-variable-by/m-p/848727#M335542</link>
      <description>&lt;P&gt;Answered my own question. Sorry thanks!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For references the solution is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data p2; set have;
meanp2=mean;
where period=2;
run;

data want; 
merge p2 have;
by group;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2022 14:50:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-variable-assigned-as-an-existing-variable-by/m-p/848727#M335542</guid>
      <dc:creator>ldavis020</dc:creator>
      <dc:date>2022-12-09T14:50:32Z</dc:date>
    </item>
  </channel>
</rss>

