<?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 variables copied into all the new rows when transposing from wide to long? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-variables-copied-into-all-the-new-rows-when/m-p/821906#M324506</link>
    <description>&lt;P&gt;Does UNIQUEADMISSION have a different value on every observation?&lt;/P&gt;
&lt;P&gt;If so then just add any other variable you want kept the same as extra BY variables after it.&lt;/P&gt;
&lt;P&gt;If you want the new variable to be named CODE instead of CODE1 (or COL1) use a RENAME= dataset option on the output dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc transpose data=totranspose2016 out=transposed2016(rename=(code1=code))
  name=diagnosis prefix=code
;
  by uniqueadmission  patientuhin cdiff primary readmit agecat died;
  var dx1-dx30;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Jul 2022 18:48:30 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-07-06T18:48:30Z</dc:date>
    <item>
      <title>How do I get variables copied into all the new rows when transposing from wide to long?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-variables-copied-into-all-the-new-rows-when/m-p/821904#M324505</link>
      <description>&lt;P&gt;I am trying to transpose from wide to long because I have 30 variables (dx1-dx30) which I'd like to put into one column with a different row for each dx variable. I want all other variables in that dataset copied for each row for those dx variables. I was able to do most of this (my dx variables worked the way I want them to and it created a new row for each of them etc) but the other variables which I'd like copied into the other rows are only being filled into the first row. In the rows for dx2-dx30, it just has a period for the other variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code I have:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc transpose data=totranspose2016 out=transposed2016 name=diagnosis prefix=code;&lt;BR /&gt;By uniqueadmission;&lt;BR /&gt;copy patientuhin cdiff primary readmit agecat died; /*want these copied to each corresponding row but only shows on first row for each&lt;BR /&gt;uniqueadmission number, then has a period for these variables in all the other rows*/&lt;BR /&gt;Var dx1-dx30; /*I want these to go from being 30 different columns to one column with one row for each dx number - this part worked*/&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to change this so the variables listed in the copy statement are copied to all of the corresponding rows?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jul 2022 18:28:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-variables-copied-into-all-the-new-rows-when/m-p/821904#M324505</guid>
      <dc:creator>Geoghegan</dc:creator>
      <dc:date>2022-07-06T18:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get variables copied into all the new rows when transposing from wide to long?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-variables-copied-into-all-the-new-rows-when/m-p/821906#M324506</link>
      <description>&lt;P&gt;Does UNIQUEADMISSION have a different value on every observation?&lt;/P&gt;
&lt;P&gt;If so then just add any other variable you want kept the same as extra BY variables after it.&lt;/P&gt;
&lt;P&gt;If you want the new variable to be named CODE instead of CODE1 (or COL1) use a RENAME= dataset option on the output dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc transpose data=totranspose2016 out=transposed2016(rename=(code1=code))
  name=diagnosis prefix=code
;
  by uniqueadmission  patientuhin cdiff primary readmit agecat died;
  var dx1-dx30;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jul 2022 18:48:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-variables-copied-into-all-the-new-rows-when/m-p/821906#M324506</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-06T18:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get variables copied into all the new rows when transposing from wide to long?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-variables-copied-into-all-the-new-rows-when/m-p/821909#M324509</link>
      <description>Perfect, thank you! That fixed it!</description>
      <pubDate>Wed, 06 Jul 2022 18:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-get-variables-copied-into-all-the-new-rows-when/m-p/821909#M324509</guid>
      <dc:creator>Geoghegan</dc:creator>
      <dc:date>2022-07-06T18:57:44Z</dc:date>
    </item>
  </channel>
</rss>

