<?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 proc transpose with by variable as numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-with-by-variable-as-numeric/m-p/802183#M315792</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a dataset that I am importing that has sales by ID by year where each year is a column name.&amp;nbsp; I want to transpose the data but I want YEAR variable to be numeric but it looks like PROC TRANSPOSE creates it as character.&amp;nbsp; Is there a way to force it to be numeric within the&amp;nbsp;PROC TRANSPOSE?&amp;nbsp; I did a quick search but couldn't find anything.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is some sample data and the&amp;nbsp;PROC TRANSPOSE that I am using.&amp;nbsp; It is the _NAME_ variable (renamed to YEAR) that I want to be numeric.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;options validvarname=any;&lt;BR /&gt;data HAVE;
	input ID $ "2018"n "2019"n "2020"n;
	datalines;
001 1000 1500 1250
002 2000 500 1800
;
run;

proc transpose
	data= HAVE
	out=  WANT (rename= (_NAME_ = YEAR COL1 = SALES));
	by ID;
	var _numeric_;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Mar 2022 13:20:50 GMT</pubDate>
    <dc:creator>GeorgeBonanza</dc:creator>
    <dc:date>2022-03-15T13:20:50Z</dc:date>
    <item>
      <title>proc transpose with by variable as numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-with-by-variable-as-numeric/m-p/802183#M315792</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a dataset that I am importing that has sales by ID by year where each year is a column name.&amp;nbsp; I want to transpose the data but I want YEAR variable to be numeric but it looks like PROC TRANSPOSE creates it as character.&amp;nbsp; Is there a way to force it to be numeric within the&amp;nbsp;PROC TRANSPOSE?&amp;nbsp; I did a quick search but couldn't find anything.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is some sample data and the&amp;nbsp;PROC TRANSPOSE that I am using.&amp;nbsp; It is the _NAME_ variable (renamed to YEAR) that I want to be numeric.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;options validvarname=any;&lt;BR /&gt;data HAVE;
	input ID $ "2018"n "2019"n "2020"n;
	datalines;
001 1000 1500 1250
002 2000 500 1800
;
run;

proc transpose
	data= HAVE
	out=  WANT (rename= (_NAME_ = YEAR COL1 = SALES));
	by ID;
	var _numeric_;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 13:20:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-with-by-variable-as-numeric/m-p/802183#M315792</guid>
      <dc:creator>GeorgeBonanza</dc:creator>
      <dc:date>2022-03-15T13:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose with by variable as numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-with-by-variable-as-numeric/m-p/802190#M315793</link>
      <description>&lt;P&gt;A variable name is by definition always character, and TRANSPOSE does not test all your variable names to see if all of them are (to the human eye) numeric. For this, you always need a second step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose
  data=have
  out=long (rename=(COL1 = SALES))
;
by ID;
var _numeric_;
run; /* PROC TRANSPOSE needs a RUN, not a QUIT! */

data want;
set long;
year = input(_name_,4.);
drop _name_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Mar 2022 13:33:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-with-by-variable-as-numeric/m-p/802190#M315793</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-15T13:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose with by variable as numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-with-by-variable-as-numeric/m-p/802206#M315795</link>
      <description>Thanks Kurt for the quick response. You've forced me to ask another question, however. I know data step uses RUN but how do I know whether to use RUN or QUIT with a PROC? I want my code to be correct so as to not look amateurish.</description>
      <pubDate>Tue, 15 Mar 2022 13:52:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-with-by-variable-as-numeric/m-p/802206#M315795</guid>
      <dc:creator>GeorgeBonanza</dc:creator>
      <dc:date>2022-03-15T13:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose with by variable as numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-with-by-variable-as-numeric/m-p/802208#M315797</link>
      <description>&lt;P&gt;There are only a few procedures who need the QUIT, as they support RUN-group processing. Think DATASETS or CATALOG. But these are few and far between &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In addition to that, SQL is a procedure that executes each statement immediately and also needs a QUIT to terminate.&lt;/P&gt;
&lt;P&gt;If in doubt about a certain procedure, look up its documentation to see if it supports RUN-group processing.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 14:04:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-with-by-variable-as-numeric/m-p/802208#M315797</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-15T14:04:09Z</dc:date>
    </item>
  </channel>
</rss>

