<?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 How do I create a new column with one variable from altenate rows containing duplicate information. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-new-column-with-one-variable-from-altenate/m-p/300630#M63514</link>
    <description>&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5054iB485ABBBAB969FD7/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="sas.JPG" title="sas.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are 6000 more rows and a few more columns. As we can see in the image, exactly half the rows have duplicate information except for one box/variable (FEV1). We want to create a new column called FEV2 (in place of E3, E4, E5...) containing value of the one unique variable in every alternate row (D4, D6, D8...) and delete the ~3000 duplicate rows. Kindly help. I can also open the file in MS Excel, so excel procedures would also be welcome.&lt;/P&gt;</description>
    <pubDate>Sun, 25 Sep 2016 17:30:48 GMT</pubDate>
    <dc:creator>akybono</dc:creator>
    <dc:date>2016-09-25T17:30:48Z</dc:date>
    <item>
      <title>How do I create a new column with one variable from altenate rows containing duplicate information.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-new-column-with-one-variable-from-altenate/m-p/300630#M63514</link>
      <description>&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5054iB485ABBBAB969FD7/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="sas.JPG" title="sas.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are 6000 more rows and a few more columns. As we can see in the image, exactly half the rows have duplicate information except for one box/variable (FEV1). We want to create a new column called FEV2 (in place of E3, E4, E5...) containing value of the one unique variable in every alternate row (D4, D6, D8...) and delete the ~3000 duplicate rows. Kindly help. I can also open the file in MS Excel, so excel procedures would also be welcome.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Sep 2016 17:30:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-new-column-with-one-variable-from-altenate/m-p/300630#M63514</guid>
      <dc:creator>akybono</dc:creator>
      <dc:date>2016-09-25T17:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a new column with one variable from altenate rows containing duplicate informati</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-new-column-with-one-variable-from-altenate/m-p/300635#M63516</link>
      <description>&lt;P&gt;Please post data as text not image, we don't want to type out your data.&lt;/P&gt;
&lt;P&gt;Also, show what you want as output based on your data&lt;/P&gt;</description>
      <pubDate>Sun, 25 Sep 2016 17:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-new-column-with-one-variable-from-altenate/m-p/300635#M63516</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-25T17:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a new column with one variable from altenate rows containing duplicate informati</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-new-column-with-one-variable-from-altenate/m-p/300636#M63517</link>
      <description>&lt;P&gt;PS. I think you want a transpose, so look into proc transpose&lt;/P&gt;</description>
      <pubDate>Sun, 25 Sep 2016 17:50:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-new-column-with-one-variable-from-altenate/m-p/300636#M63517</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-25T17:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a new column with one variable from altenate rows containing duplicate informati</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-new-column-with-one-variable-from-altenate/m-p/300647#M63523</link>
      <description>&lt;P&gt;Here's a (perhaps) simpler approach that doesn't require learning PROC TRANSPOSE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have (rename=(fev1=fev));&lt;/P&gt;
&lt;P&gt;by mrn dos bmi;&lt;/P&gt;
&lt;P&gt;fev2 = fev;&lt;/P&gt;
&lt;P&gt;fev1 = lag(fev);&lt;/P&gt;
&lt;P&gt;if last.bmi;&lt;/P&gt;
&lt;P&gt;drop fev;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It does require, however, that there are exactly two observations to be combined each time. &amp;nbsp;If that's not the case, you can still use a more complex DATA step or else switch to PROC TRANSPOSE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc transpose data=have (rename=(fev1=fev)) prefix=fev out=want (drop=_name_);&lt;/P&gt;
&lt;P&gt;var fev;&lt;/P&gt;
&lt;P&gt;by mrn dos bmi;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The programs are untested ... likely working as is but you may need to tweak them.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Sep 2016 20:46:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-new-column-with-one-variable-from-altenate/m-p/300647#M63523</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-25T20:46:26Z</dc:date>
    </item>
  </channel>
</rss>

