<?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: Trouble renaming variable after transposing in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634212#M77952</link>
    <description>&lt;P&gt;You'll have to rename it in whatever the next step is.&lt;/P&gt;</description>
    <pubDate>Mon, 23 Mar 2020 18:53:36 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-03-23T18:53:36Z</dc:date>
    <item>
      <title>Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634203#M77947</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset that I transposed, however, I am trying to rename an id variable (ptid) before I merge this dataset with another one. I don't get an error message but after running the rename statement, it does not change the variable in the dataset (and when I run a proc contents to see the variable name, it says the variable (and label) are ptid). Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;This is the code I ran to transpose the dataset (would this have cause any issues with my renaming):&amp;nbsp;&lt;/P&gt;&lt;P&gt;data heartcount;&lt;BR /&gt;set newresults;&lt;BR /&gt;array diag (24) diag1-diag24;&lt;BR /&gt;heart=0;&lt;BR /&gt;do _n_=1 to dim(diag);&lt;BR /&gt;if diag{_n_}in: ("250","E11","E10") then heart+1;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;trying to rename variable and sort dataset before I merge:&lt;/P&gt;&lt;P&gt;proc sort data = heartcount out=ribdata (rename= ptid=idnum);&lt;BR /&gt;by ptid;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 18:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634203#M77947</guid>
      <dc:creator>monsterpie</dc:creator>
      <dc:date>2020-03-23T18:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634204#M77948</link>
      <description>&lt;P&gt;You don't get an error message, but the code you show absolutely will produce an error message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The proper syntax is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data = ex.spine out=spine2 (rename=(ptid=idnum));
by ptid;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note the extra parentheses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that doesn't work for you, please show us the entire log for these steps (code as seen in the log, plus any errors or warnings, do not chop out any part of the log for these steps).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 18:27:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634204#M77948</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-23T18:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634206#M77949</link>
      <description>&lt;P&gt;Hi Paige, this is the log I get for when I try the correct syntax you provided:&lt;/P&gt;&lt;P&gt;364 proc sort data = heartcount out= spine2 (rename=(ptid=idnum));&lt;BR /&gt;365 by ptid;&lt;BR /&gt;366 run;&lt;/P&gt;&lt;P&gt;NOTE: Input data set is already sorted; it has been copied to the output data set.&lt;BR /&gt;NOTE: There were 32844 observations read from the data set WORK.HEARTCOUNT.&lt;BR /&gt;NOTE: The data set WORK.SPINE2 has 32844 observations and 28 variables.&lt;BR /&gt;NOTE: PROCEDURE SORT used (Total process time):&lt;BR /&gt;real time 0.02 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 18:36:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634206#M77949</guid>
      <dc:creator>monsterpie</dc:creator>
      <dc:date>2020-03-23T18:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634209#M77950</link>
      <description>&lt;P&gt;If you read the log, it explains why no sorting was done, and why the variable is not renamed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;NOTE: Input data set is already sorted; it has been copied to the output data set.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 23 Mar 2020 18:53:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634209#M77950</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-23T18:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634211#M77951</link>
      <description>yes, the issue is that in spine2 (or even if I just try to rename it in the original dataset - heartcount) it does not get renamed.</description>
      <pubDate>Mon, 23 Mar 2020 18:53:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634211#M77951</guid>
      <dc:creator>monsterpie</dc:creator>
      <dc:date>2020-03-23T18:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634212#M77952</link>
      <description>&lt;P&gt;You'll have to rename it in whatever the next step is.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 18:53:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634212#M77952</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-23T18:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634213#M77953</link>
      <description>well my next step is to merge spine2 with another dataset. But I thought that you had to rename id variables to match before merging two datasets? Hence why I was trying to rename pt id to idnum (which is in the other dataset that I will be merging with)</description>
      <pubDate>Mon, 23 Mar 2020 18:55:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634213#M77953</guid>
      <dc:creator>monsterpie</dc:creator>
      <dc:date>2020-03-23T18:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634218#M77954</link>
      <description>&lt;P&gt;Are you sure you aren't looking at the LABEL instead of the NAME of the variable.&lt;/P&gt;
&lt;P&gt;It definitely works for me, even when the data is sorted already.&lt;/P&gt;
&lt;PRE&gt;2897  proc sort data=sashelp.class out=class ; by sex; run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.CLASS has 19 observations and 5 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.04 seconds
      cpu time            0.01 seconds


2898  proc sort data=class(rename=(name=name2)) out=class2; by sex; run;

NOTE: Input data set is already sorted; it has been copied to the output data set.
NOTE: There were 19 observations read from the data set WORK.CLASS.
NOTE: The data set WORK.CLASS2 has 19 observations and 5 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


2899  proc compare data=class compare=class2; run;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;Data Set Summary

Dataset               Created          Modified  NVar    NObs  Label

WORK.CLASS   23MAR20:14:56:21  23MAR20:14:56:21     5      19  Student Data
WORK.CLASS2  23MAR20:14:56:21  23MAR20:14:56:21     5      19  Student Data


Variables Summary

Number of Variables in Common: 4.
&lt;FONT color="#FF0000"&gt;Number of Variables in WORK.CLASS but not in WORK.CLASS2: 1.
Number of Variables in WORK.CLASS2 but not in WORK.CLASS: 1.
&amp;#12;&lt;/FONT&gt;
SAS 9.4 on WINDOWS                                                       13:12 Thursday, March 19, 2020  44

The COMPARE Procedure
Comparison of WORK.CLASS with WORK.CLASS2
(Method=EXACT)

Observation Summary

Observation      Base  Compare

First Obs           1        1
Last  Obs          19       19

Number of Observations in Common: 19.
Total Number of Observations Read from WORK.CLASS: 19.
Total Number of Observations Read from WORK.CLASS2: 19.

Number of Observations with Some Compared Variables Unequal: 0.
Number of Observations with All Compared Variables Equal: 19.

NOTE: No unequal values were found. All values compared are exactly equal.&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Mar 2020 19:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634218#M77954</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-23T19:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634222#M77955</link>
      <description>I just ran the code again and it still doesn't seem to work...but I am going through all my steps again, and I'm just wondering if there is a way to rename ptid in the proc transpose statement?</description>
      <pubDate>Mon, 23 Mar 2020 19:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634222#M77955</guid>
      <dc:creator>monsterpie</dc:creator>
      <dc:date>2020-03-23T19:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634224#M77956</link>
      <description>&lt;P&gt;Yes you can rename it during PROC TRANSPOSE, or you can rename in the step where you do the merge.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 19:13:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634224#M77956</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-23T19:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634225#M77957</link>
      <description>would you be able to give me an example of either of those syntaxes please?</description>
      <pubDate>Mon, 23 Mar 2020 19:14:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634225#M77957</guid>
      <dc:creator>monsterpie</dc:creator>
      <dc:date>2020-03-23T19:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634226#M77958</link>
      <description>Yes.  The OUT= option of PROC TRANSPOSE is a dataset reference. So you can include dataset options. Which include the RENAME= option.&lt;BR /&gt;</description>
      <pubDate>Mon, 23 Mar 2020 19:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634226#M77958</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-23T19:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634231#M77959</link>
      <description>ok,so I ran this on a different set of data but even in this data the variable is not renamed in the new dataset.&lt;BR /&gt;Proc transpose data=shortdiag&lt;BR /&gt;out=newresults2 (rename=(hdghraencwid=hraencwid))&lt;BR /&gt;prefix=diag;&lt;BR /&gt;by hdgHraEncWid;&lt;BR /&gt;var diagnosis;&lt;BR /&gt;run;</description>
      <pubDate>Mon, 23 Mar 2020 19:21:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634231#M77959</guid>
      <dc:creator>monsterpie</dc:creator>
      <dc:date>2020-03-23T19:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634242#M77960</link>
      <description>&lt;P&gt;I really doubt that RENAME= option is not working for you.&amp;nbsp; You are either looking at the wrong dataset or not looking at the NAME of the variable.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please show the proc contents for the dataset&amp;nbsp;&lt;SPAN&gt;newresults2.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 19:28:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634242#M77960</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-23T19:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634245#M77961</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;You can definitely rename within a sort and you do not need brackets around the rename if it's only one set of variables so that's not the issue with OP's code, something else is the issue. This code works perfectly fine and the class2 data set has the renamed variable as indicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
set sashelp.class;
run;

proc sort data=class;
by sex age;
run;

proc sort data=class out=class2(rename=name=ID);
by sex age;
run;

proc contents data=class2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Mar 2020 19:35:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634245#M77961</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-03-23T19:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634246#M77962</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I really doubt that RENAME= option is not working for you.&amp;nbsp; You are either looking at the wrong dataset or not looking at the NAME of the variable.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please show the proc contents for the dataset&amp;nbsp;&lt;SPAN&gt;newresults2.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Agreed.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 19:35:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634246#M77962</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-03-23T19:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634249#M77963</link>
      <description>&lt;P&gt;The log provided explains why the variable was not renamed via PROC SORT&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 19:38:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634249#M77963</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-23T19:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634251#M77964</link>
      <description>It doesn't indicate any issue with renaming as far as I can see, it says the data set is not sorted but it also says the second data set is created and that shows the rename correctly. I could be missing something but I think both Tom and my example show the code is valid and correct.</description>
      <pubDate>Mon, 23 Mar 2020 19:39:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634251#M77964</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-03-23T19:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634252#M77965</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/318138"&gt;@monsterpie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;ok,so I ran this on a different set of data but even in this data the variable is not renamed in the new dataset.&lt;BR /&gt;Proc transpose data=shortdiag&lt;BR /&gt;out=newresults2 (rename=(hdghraencwid=hraencwid))&lt;BR /&gt;prefix=diag;&lt;BR /&gt;by hdgHraEncWid;&lt;BR /&gt;var diagnosis;&lt;BR /&gt;run;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Show the log.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 19:40:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634252#M77965</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-03-23T19:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble renaming variable after transposing</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634394#M77966</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;It doesn't indicate any issue with renaming as far as I can see, it says the data set is not sorted but it also says the second data set is created and that shows the rename correctly. I could be missing something but I think both Tom and my example show the code is valid and correct.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The log said:&lt;BR /&gt;"NOTE: Input data set is already sorted; &lt;FONT color="#FF0000"&gt;it has been copied&lt;/FONT&gt; to the output data set."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you make a copy, the variable names are not changed.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 10:36:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Trouble-renaming-variable-after-transposing/m-p/634394#M77966</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-24T10:36:52Z</dc:date>
    </item>
  </channel>
</rss>

