<?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 copy each row to the row above it they have same ID in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/866037#M342011</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hi, I have this data&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data regd.have; input id $ year $ FD $ REPORTING $ variable3 $ variable4 $ variable5 $ variable6 $ variable7;datalines;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;x 1999 0 1 0 1 0 0 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;x 2005 1 1 1 1 1 1 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;x 2006 0 1 0 1 0 0 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;y 1989 1 1 1 1 1 1 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;y 2010 0 1 0 1 0 0 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to condense all IDs to 1 row so my data will look like this:, Meaning i want to copy each row to the row above - if it has same cik.&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;id year variable 2 variable 3 variable 4 variable 5 variable 6 variable 8 year variable 7 variable 3 variable 4 variable 5 variable 6 variable 8 year variable 2 variable 3 variable 4 variable 5 variable 6 variable 7&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;id year variable 2 variable 3 variable 4 variable 5 variable 6 variable 8 year variable 7 variable 3 variable 4 variable 5 variable 6 variable 8 year variable 2 variable 3 variable 4 variable 5 variable 6 variable 7&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;x 1999 0 1 0 1 0 0 2005 1 1 1 1 1 1 2006 0 1 0 1 0 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;y 1989 1 1 1 1 1 1 2010 0 1 0 1 0 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;z 2000 1 1 1 1 1 1 2003 0 1 0 1 0 0 2004 1 1 1 1 1 1&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Mar 2023 06:57:32 GMT</pubDate>
    <dc:creator>HEB1</dc:creator>
    <dc:date>2023-03-24T06:57:32Z</dc:date>
    <item>
      <title>condense data in multiple id to 1 id row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/865883#M341952</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;my data looks like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have; input id $ year variable1 variable2&amp;nbsp;variable3&amp;nbsp;variable4&amp;nbsp;variable5&amp;nbsp;variable6&amp;nbsp;variable7&lt;/P&gt;&lt;P&gt;x 1999 0 1 0 1 0 0&lt;BR /&gt;x 2005 1 1 1 1 1 1&lt;BR /&gt;x 2006 0 1 0 1 0 0&lt;BR /&gt;y 1989 1 1 1 1 1 1&lt;BR /&gt;y 2010 0 1 0 1 0 0&lt;/P&gt;&lt;P&gt;I want to condense all IDs to 1 row so my data will look like this:&lt;/P&gt;&lt;P&gt;id year variable 2 variable 3 variable 4 variable 5 variable 6 variable 8 year variable 7 variable 3 variable 4 variable 5 variable 6 variable 8 year variable 2 variable 3 variable 4 variable 5 variable 6 variable 7&lt;BR /&gt;id year variable 2 variable 3 variable 4 variable 5 variable 6 variable 8 year variable 7 variable 3 variable 4 variable 5 variable 6 variable 8 year variable 2 variable 3 variable 4 variable 5 variable 6 variable 7&lt;BR /&gt;x 1999 0 1 0 1 0 0 2005 1 1 1 1 1 1 2006 0 1 0 1 0 0&lt;BR /&gt;y 1989 1 1 1 1 1 1 2010 0 1 0 1 0 0&lt;BR /&gt;z 2000 1 1 1 1 1 1 2003 0 1 0 1 0 0 2004 1 1 1 1 1 1&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 10:21:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/865883#M341952</guid>
      <dc:creator>HEB1</dc:creator>
      <dc:date>2023-03-23T10:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: condense data in multiple id to 1 id row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/865885#M341954</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; input id $ year variable1 variable2 variable3 variable4 variable5 variable6 variable7

x 1999 0 1 0 1 0 0
x 2005 1 1 1 1 1 1
x 2006 0 1 0 1 0 0
y 1989 1 1 1 1 1 1
y 2010 0 1 0 1 0 0&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is not working SAS code. Could you please fix it (and also please test your code before you provide it). Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 10:24:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/865885#M341954</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-23T10:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: condense data in multiple id to 1 id row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/865898#M341963</link>
      <description>&lt;P&gt;data regd.have; input id $ year $ variable1 $ variable2 $ variable3 $ variable4 $ variable5 $ variable6 $ variable7;datalines;&lt;/P&gt;&lt;P&gt;x 1999 0 1 0 1 0 0 0&lt;BR /&gt;x 2005 1 1 1 1 1 1 0&lt;BR /&gt;x 2006 0 1 0 1 0 0 0&lt;BR /&gt;y 1989 1 1 1 1 1 1 0&lt;BR /&gt;y 2010 0 1 0 1 0 0 0&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the correct code for the data&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 11:38:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/865898#M341963</guid>
      <dc:creator>HEB1</dc:creator>
      <dc:date>2023-03-23T11:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: condense data in multiple id to 1 id row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/865906#M341967</link>
      <description>data regd.have; input id $ year $ variable1 $ variable2 $ variable3 $ variable4 $ variable5 $ variable6 $ variable7;datalines;&lt;BR /&gt;&lt;BR /&gt;x 1999 0 1 0 1 0 0 0&lt;BR /&gt;x 2005 1 1 1 1 1 1 0&lt;BR /&gt;x 2006 0 1 0 1 0 0 0&lt;BR /&gt;y 1989 1 1 1 1 1 1 0&lt;BR /&gt;y 2010 0 1 0 1 0 0 0&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;I want to condense all IDs to 1 row so my data will look like this:&lt;BR /&gt;&lt;BR /&gt;id year variable 2 variable 3 variable 4 variable 5 variable 6 variable 8 year variable 7 variable 3 variable 4 variable 5 variable 6 variable 8 year variable 2 variable 3 variable 4 variable 5 variable 6 variable 7&lt;BR /&gt;id year variable 2 variable 3 variable 4 variable 5 variable 6 variable 8 year variable 7 variable 3 variable 4 variable 5 variable 6 variable 8 year variable 2 variable 3 variable 4 variable 5 variable 6 variable 7&lt;BR /&gt;x 1999 0 1 0 1 0 0 2005 1 1 1 1 1 1 2006 0 1 0 1 0 0&lt;BR /&gt;y 1989 1 1 1 1 1 1 2010 0 1 0 1 0 0&lt;BR /&gt;z 2000 1 1 1 1 1 1 2003 0 1 0 1 0 0 2004 1 1 1 1 1 1&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Mar 2023 12:10:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/865906#M341967</guid>
      <dc:creator>HEB1</dc:creator>
      <dc:date>2023-03-23T12:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: condense data in multiple id to 1 id row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/865911#M341968</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
input id $ year $ variable1 $ variable2 $ variable3 $ variable4 $ variable5 $ variable6 $ variable7;
datalines;
x 1999 0 1 0 1 0 0 0
x 2005 1 1 1 1 1 1 0
x 2006 0 1 0 1 0 0 0
y 1989 1 1 1 1 1 1 0
y 2010 0 1 0 1 0 0 0
;
data temp;
 set have;
 by id;
 if first.id then n=0;
 n+1;
run;
proc sql noprint;
select distinct catt('temp(where=(n=',n,') rename=(year=year',n,' variable1-variable7=variable',n,'_1-variable',n,'_7))')
 into : merge separated by ' ' 
 from temp;
quit;
data want;
 merge &amp;amp;merge.;
 by id;
 drop n;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Mar 2023 12:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/865911#M341968</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-03-23T12:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: condense data in multiple id to 1 id row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/865915#M341969</link>
      <description>Hi,&lt;BR /&gt;I don't understand this row:&lt;BR /&gt;rename=(year=year',n,' variable1-variable7=variable',n,'_1-variable',n,'_7))')&lt;BR /&gt;do I need to write over there the right names of each of the variables?</description>
      <pubDate>Thu, 23 Mar 2023 12:35:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/865915#M341969</guid>
      <dc:creator>HEB1</dc:creator>
      <dc:date>2023-03-23T12:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: condense data in multiple id to 1 id row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/865920#M341970</link>
      <description>&lt;P&gt;A&amp;nbsp;&lt;EM&gt;dataset&lt;/EM&gt; structure like this is not possible, as you cannot have multiple variables with the same name.&lt;/P&gt;
&lt;P&gt;Also, such a wide structure is VERY hard to handle in future code; it only makes sense if this is to be a report for human consumption.&lt;/P&gt;
&lt;P&gt;So, shall this be a report?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 13:07:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/865920#M341970</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-23T13:07:50Z</dc:date>
    </item>
    <item>
      <title>copy each row to the row above it they have same ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/866037#M342011</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi, I have this data&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data regd.have; input id $ year $ FD $ REPORTING $ variable3 $ variable4 $ variable5 $ variable6 $ variable7;datalines;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;x 1999 0 1 0 1 0 0 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;x 2005 1 1 1 1 1 1 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;x 2006 0 1 0 1 0 0 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;y 1989 1 1 1 1 1 1 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;y 2010 0 1 0 1 0 0 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to condense all IDs to 1 row so my data will look like this:, Meaning i want to copy each row to the row above - if it has same cik.&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;id year variable 2 variable 3 variable 4 variable 5 variable 6 variable 8 year variable 7 variable 3 variable 4 variable 5 variable 6 variable 8 year variable 2 variable 3 variable 4 variable 5 variable 6 variable 7&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;id year variable 2 variable 3 variable 4 variable 5 variable 6 variable 8 year variable 7 variable 3 variable 4 variable 5 variable 6 variable 8 year variable 2 variable 3 variable 4 variable 5 variable 6 variable 7&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;x 1999 0 1 0 1 0 0 2005 1 1 1 1 1 1 2006 0 1 0 1 0 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;y 1989 1 1 1 1 1 1 2010 0 1 0 1 0 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;z 2000 1 1 1 1 1 1 2003 0 1 0 1 0 0 2004 1 1 1 1 1 1&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 06:57:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/866037#M342011</guid>
      <dc:creator>HEB1</dc:creator>
      <dc:date>2023-03-24T06:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: copy each row to the row above it they have same ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/866042#M342012</link>
      <description>&lt;P&gt;Please do not start new threads for the same question.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 07:29:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/866042#M342012</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-24T07:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: condense data in multiple id to 1 id row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/866090#M342029</link>
      <description>&lt;PRE&gt;Yes. you need to write right variable names if your variable names are different with variable1 variable2.....

My macro variable contains the following code :

temp(where=(n=1) rename=(year=year1 variable1-variable7=variable1_1-variable1_7)) 
temp(where=(n=2) rename=(year=year2 variable1-variable7=variable2_1-variable2_7)) 
temp(where=(n=3) rename=(year=year3 variable1-variable7=variable3_1-variable3_7)) 
&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Mar 2023 11:58:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/condense-data-in-multiple-id-to-1-id-row/m-p/866090#M342029</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-03-24T11:58:10Z</dc:date>
    </item>
  </channel>
</rss>

