<?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: Using prefix before a variable in proc transpose in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-prefix-before-a-variable-in-proc-transpose/m-p/814153#M321375</link>
    <description>&lt;P&gt;I suspect that you would be a lot better served to use PROC SUMMARY and the IDGROUP concept to transpose your data since this will allow you to transpose multiple variables at once.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings10/102-2010.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings10/102-2010.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 May 2022 18:30:52 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-05-18T18:30:52Z</dc:date>
    <item>
      <title>Using prefix before a variable in proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-prefix-before-a-variable-in-proc-transpose/m-p/814116#M321344</link>
      <description>&lt;P&gt;Dear Users,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to have a prefix before each variable is created instead of _1, _2, _3&lt;/P&gt;
&lt;P&gt;when I run the following: (actually&amp;nbsp;&lt;CODE class=" language-sas"&gt;BHARced_1&amp;nbsp;BHARced_2&amp;nbsp;BHARced_3&amp;nbsp;and&amp;nbsp;then&amp;nbsp;for&amp;nbsp;the&amp;nbsp;second&amp;nbsp;BHRced_1..&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;
*move the quarters as columns;
%let varlist = BHARced BHRced;

%macro rename;
   %let word_cnt=%sysfunc(countw(&amp;amp;varlist)); 
   %do i = 1 %to &amp;amp;word_cnt; 
     %let temp=%qscan(%bquote(&amp;amp;varlist),&amp;amp;i);
	    proc transpose data=dsf4(keep=cusip year_performance &amp;amp;temp )
					out=performance_&amp;amp;i
					name= &amp;amp;temp;
					id year_performance;
	                *prefix= &amp;amp;name;
					by cusip ;
					
	    run;
        data performance_&amp;amp;i(rename=(_1= 1_&amp;amp;temp _2= 2_&amp;amp;temp _3=3_&amp;amp;temp));/*there is a proble, here*/
		     set performance_&amp;amp;i;
		run;

   %end;
%mend rename;
%rename;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log output:&lt;/P&gt;
&lt;PRE&gt;MPRINT(RENAME):   proc transpose data=dsf4(keep=cusip year_performance BHARced )
out=performance_1 name= BHARced;
MPRINT(RENAME):   id year_performance;
MPRINT(RENAME):   *prefix= &amp;amp;name;
MPRINT(RENAME):   by cusip ;
MPRINT(RENAME):   run;

NOTE: There were 3301 observations read from the data set WORK.DSF4.
NOTE: The data set WORK.PERFORMANCE_1 has 1186 observations and 5 variables.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
      real time           0.02 seconds
      cpu time            0.00 seconds


214: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN
      where the error has occurred.
ERROR 214-322: Variable name 1 is not valid.
NOTE 138-205: Line generated by the macro variable "TEMP".
1     _BHARced
       -------
       79
ERROR 79-322: Expecting a =.

23: LINE and COLUMN cannot be determined.
NOTE 242-205: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and
              COLUMN where the error has occurred.
ERROR 23-7: Invalid value for the RENAME option.
MPRINT(RENAME):   data performance_1(rename=(_1= 1_BHARced _2= 2_BHARced _3=3_BHARced));
MPRINT(RENAME):   set performance_1;
MPRINT(RENAME):   run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


MPRINT(RENAME):   proc transpose data=dsf4(keep=cusip year_performance BHRced ) out=performance_2
name= BHRced;
MPRINT(RENAME):   id year_performance;
MPRINT(RENAME):   *prefix= &amp;amp;name;
MPRINT(RENAME):   by cusip ;
MPRINT(RENAME):   run;

NOTE: There were 3301 observations read from the data set WORK.DSF4.
NOTE: The data set WORK.PERFORMANCE_2 has 1186 observations and 5 variables.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
      real time           0.02 seconds
      cpu time            0.00 seconds


214: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN
      where the error has occurred.
ERROR 214-322: Variable name 1 is not valid.
NOTE 138-205: Line generated by the macro variable "TEMP".
1     _BHRced
       ------
       79
ERROR 79-322: Expecting a =.

23: LINE and COLUMN cannot be determined.
NOTE 242-205: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and
              COLUMN where the error has occurred.
ERROR 23-7: Invalid value for the RENAME option.
MPRINT(RENAME):   data performance_2(rename=(_1= 1_BHRced _2= 2_BHRced _3=3_BHRced));
MPRINT(RENAME):   set performance_2;
MPRINT(RENAME):   run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds



&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much&amp;nbsp;&lt;SPAN&gt;PaigeMiller for your great guidelines&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 17:11:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-prefix-before-a-variable-in-proc-transpose/m-p/814116#M321344</guid>
      <dc:creator>georgel</dc:creator>
      <dc:date>2022-05-18T17:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using prefix before a variable in proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-prefix-before-a-variable-in-proc-transpose/m-p/814125#M321350</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*there is a proble, here*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whenever code isn't working right, we normally ask to see the LOG. We need to see the &lt;FONT color="#FF0000"&gt;ENTIRE&lt;/FONT&gt; log for this macro, every single line, every single character; do not pick and choose parts of the log to show us. Copy the log as text and paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-11-26 08_27_29-Reply to Message - SAS Support Communities — Mozilla Firefox.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66123iA4EF494F9CA0F6EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-11-26 08_27_29-Reply to Message - SAS Support Communities — Mozilla Firefox.png" alt="2021-11-26 08_27_29-Reply to Message - SAS Support Communities — Mozilla Firefox.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition, since it is a macro problem, please run this line and then run your code again and show us that log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From now on, we expect you to show us the LOG every single time you have an error or problem.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 17:00:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-prefix-before-a-variable-in-proc-transpose/m-p/814125#M321350</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-18T17:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using prefix before a variable in proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-prefix-before-a-variable-in-proc-transpose/m-p/814127#M321352</link>
      <description>&lt;P&gt;PREFIX= is an option of the PROC TRANSPOSE statement.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 17:09:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-prefix-before-a-variable-in-proc-transpose/m-p/814127#M321352</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-05-18T17:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using prefix before a variable in proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-prefix-before-a-variable-in-proc-transpose/m-p/814130#M321354</link>
      <description>&lt;P&gt;Prefix option goes into the PROC statement.&lt;/P&gt;
&lt;P&gt;This example will PREFIX the name of the variable with ABC before the value of the ID variable.&lt;/P&gt;
&lt;PRE&gt;proc transpose data=sashelp.class(obs=5)
     out =trans prefix=ABC;
   by name;
   var age;
   id sex;
run;&lt;/PRE&gt;
&lt;P&gt;The obs limit is just to make a very small set easy to read.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 17:13:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-prefix-before-a-variable-in-proc-transpose/m-p/814130#M321354</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-05-18T17:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using prefix before a variable in proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-prefix-before-a-variable-in-proc-transpose/m-p/814153#M321375</link>
      <description>&lt;P&gt;I suspect that you would be a lot better served to use PROC SUMMARY and the IDGROUP concept to transpose your data since this will allow you to transpose multiple variables at once.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings10/102-2010.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings10/102-2010.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 18:30:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-prefix-before-a-variable-in-proc-transpose/m-p/814153#M321375</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-18T18:30:52Z</dc:date>
    </item>
  </channel>
</rss>

