<?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: label variables as their real name during proc transpose in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/label-variables-as-their-real-name-during-proc-transpose/m-p/750635#M236143</link>
    <description>You are the best!!&lt;BR /&gt;Thank you&lt;BR /&gt;</description>
    <pubDate>Sun, 27 Jun 2021 03:59:51 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2021-06-27T03:59:51Z</dc:date>
    <item>
      <title>label variables as their real name during proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/label-variables-as-their-real-name-during-proc-transpose/m-p/750609#M236134</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;What is the way that wanted data set will have labels for columns same as variables names?&lt;/P&gt;
&lt;P&gt;It means that :&lt;/P&gt;
&lt;P&gt;label of variable Wealth1 will be Wealth1&lt;/P&gt;
&lt;P&gt;label of variable Wealth2 will be Wealth2&lt;/P&gt;
&lt;P&gt;label of variable Wealth3 will be Wealth3&lt;/P&gt;
&lt;P&gt;label of variable Wealth4 will be Wealth4&lt;/P&gt;
&lt;P&gt;label of variable Wealth5 will be Wealth5&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
label wealth='Stocks wealth';
input CustID month wealth;
cards;
1 2101 10
1 2102 20
1 2103 30
1 2104 40
1 2105 50
2 2101 5
2 2102 10
2 2103 15
2 2104 20
2 2105 25
;
Run;
proc transpose data=have  out=Want (drop=_name_ ) prefix=wealth;
VAR wealth ;
BY CustID ;
Run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jun 2021 17:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/label-variables-as-their-real-name-during-proc-transpose/m-p/750609#M236134</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-06-26T17:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: label variables as their real name during proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/label-variables-as-their-real-name-during-proc-transpose/m-p/750623#M236139</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=Want (drop=_name_ _label_) prefix=wealth; 
  VAR wealth ; 
  BY CustID ; 
   idlabel wealth; 
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;NB:&amp;nbsp; So the following works, but i think you might need to have a variable which creates a name for the value that was transposed.&lt;/P&gt;
&lt;P&gt;If the variable was present, then we would&amp;nbsp; have used an id statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jun 2021 19:10:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/label-variables-as-their-real-name-during-proc-transpose/m-p/750623#M236139</guid>
      <dc:creator>himself</dc:creator>
      <dc:date>2021-06-26T19:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: label variables as their real name during proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/label-variables-as-their-real-name-during-proc-transpose/m-p/750628#M236140</link>
      <description>&lt;P&gt;I don't understand what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the output dataset not to have the variable _LABEL_ then either drop it like you did _NAME_ or remove the label in the PROC TRANSPOSE step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have  out=Want (drop=_name_ ) prefix=wealth;
  by CustID ;
  var wealth ;
  label wealth=' ';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the want the LABEL to be the same as the NAME then just leave the LABEL empty and where ever SAS would normally display the label instead of the name it will just use the name.&amp;nbsp; Try it yourself and see.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=want;
run;

proc print data=want label;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to have full control over the name (and label) then add those variables to your data and use the ID and IDLABEL statements.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data for_transpose;
  set have;
  by custid ;
  length name $32 label $256 ;
  name=cats('wealth',month);
  label=catx(' ','Wealth for month',month);
run;
proc transpose data=for_transpose  out=Want (drop=_name_ );
  by CustID ;
  id name;
  idlabel label;
  var wealth ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 639px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60777i6540CCA6E4FDB075/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jun 2021 22:20:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/label-variables-as-their-real-name-during-proc-transpose/m-p/750628#M236140</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-26T22:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: label variables as their real name during proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/label-variables-as-their-real-name-during-proc-transpose/m-p/750635#M236143</link>
      <description>You are the best!!&lt;BR /&gt;Thank you&lt;BR /&gt;</description>
      <pubDate>Sun, 27 Jun 2021 03:59:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/label-variables-as-their-real-name-during-proc-transpose/m-p/750635#M236143</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-06-27T03:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: label variables as their real name during proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/label-variables-as-their-real-name-during-proc-transpose/m-p/750636#M236144</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;As you can see in the code you wrote there are no labels in the new data set that was created&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jun 2021 04:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/label-variables-as-their-real-name-during-proc-transpose/m-p/750636#M236144</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-06-27T04:00:51Z</dc:date>
    </item>
  </channel>
</rss>

