<?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: Rename and re-position variables on same row - Proc Transpose in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rename-and-re-position-variables-on-same-row-Proc-Transpose/m-p/734877#M228931</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Order of variables in a data set is one of the lowest priority things I can think of doing though apparently many people seem to think it is needed. Anything done inside SAS basically does not care.&lt;/P&gt;
&lt;P&gt;If a file you are sending to an output file needs a specific order then create that file at that time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise you can spend a lot of time fooling around with (ever changing) minutia that actually wastes time and makes code hard to follow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, why is a specific order of variables/ variable names &lt;STRONG&gt;needed&lt;/STRONG&gt;?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can think of a few activities I commonly do in which knowing/using variable order is "needed":&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;When displaying the data&lt;/LI&gt;
&lt;LI&gt;Expecting the identifier variables (id/date/time/...) to consistently be in a particular position&lt;/LI&gt;
&lt;LI&gt;Variable clusters - i.e.&amp;nbsp; &amp;nbsp;6 groups of 5 attributes arranged contiguously&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;True, the above are for looking at the data, not programming.&amp;nbsp; But I often take advantage of variable order in programming as well, mostly through use of the double dash as a means of generating a list of variable names or array declarations, typically to avoid listing lots of variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or it can also be useful when I might not actually know the variable names of interest.&amp;nbsp; For example: let's say that I want to interleave A and B, but keep only the variables present in dataset A:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  if 0 then set a;
  retain _sentinel1 .;
  if 0 then set b;
  retain _sentinel2 .;
  set a b;
  by id;
  drop _sentinel1--_sentinel2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Yes, this can be done directly in SQL, but there are often many reasons to use a data step instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 17 Apr 2021 14:09:47 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2021-04-17T14:09:47Z</dc:date>
    <item>
      <title>Rename and re-position variables on same row - Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-and-re-position-variables-on-same-row-Proc-Transpose/m-p/734752#M228887</link>
      <description>I am unable to replicate this in a test dataset however please look at this.  have is a proc transpose.  Notice the cascading variables that end in PCT.  Is there a way to rename the four in _NAME_ to something like Stay_Curr and let all entries appear on the same row in order as seen in the want-proc transpose (or some other routine)??

have - proc transpose							
Group	Category	_NAME_	DEC20	JAN21	FEB21	MAR21	APR21
Current	Count	Count_	736422	730405	722577	721558	704774
Current	Count	_04_Stay_Pct	0.94515373	1	1	1	1
Current	Count	_03_Stay_Pct	1	0.951110685	1	1	1
Current	Count	_02_Stay_Pct	1	1	0.951131852	1	1
Current	Count	_01_Stay_Pct	1	1	1	0.95324423	1
Current	Count	_00_Stay_Pct	1	1	1	1	0.956489598
							
							
want-proc transpose							
Group	Category	_NAME_	DEC20	JAN21	FEB21	MAR21	APR21
Current	Count	Count_	736422	730405	722577	721558	704774
Current	Count	Stay_Curr_Pct	0.94515373	0.951110685	0.951131852	0.95324423	0.956489598</description>
      <pubDate>Fri, 16 Apr 2021 15:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-and-re-position-variables-on-same-row-Proc-Transpose/m-p/734752#M228887</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2021-04-16T15:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: Rename and re-position variables on same row - Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-and-re-position-variables-on-same-row-Proc-Transpose/m-p/734774#M228889</link>
      <description>Unfortunately your question is garbled enough to not be legible at this point. &lt;BR /&gt;Can you please edit it?&lt;BR /&gt;&lt;BR /&gt;Please show what you've tried as well.</description>
      <pubDate>Fri, 16 Apr 2021 16:40:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-and-re-position-variables-on-same-row-Proc-Transpose/m-p/734774#M228889</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-16T16:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: Rename and re-position variables on same row - Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-and-re-position-variables-on-same-row-Proc-Transpose/m-p/734800#M228898</link>
      <description>&lt;P&gt;Order of variables in a data set is one of the lowest priority things I can think of doing though apparently many people seem to think it is needed. Anything done inside SAS basically does not care.&lt;/P&gt;
&lt;P&gt;If a file you are sending to an output file needs a specific order then create that file at that time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise you can spend a lot of time fooling around with (ever changing) minutia that actually wastes time and makes code hard to follow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, why is a specific order of variables/ variable names &lt;STRONG&gt;needed&lt;/STRONG&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You already likely have too many variables with data in the names, Mon and Year for example. and your "Count_00" "Count_01" are agravating that for most actual processing/analysis.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 20:38:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-and-re-position-variables-on-same-row-Proc-Transpose/m-p/734800#M228898</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-16T20:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: Rename and re-position variables on same row - Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-and-re-position-variables-on-same-row-Proc-Transpose/m-p/734877#M228931</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Order of variables in a data set is one of the lowest priority things I can think of doing though apparently many people seem to think it is needed. Anything done inside SAS basically does not care.&lt;/P&gt;
&lt;P&gt;If a file you are sending to an output file needs a specific order then create that file at that time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise you can spend a lot of time fooling around with (ever changing) minutia that actually wastes time and makes code hard to follow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, why is a specific order of variables/ variable names &lt;STRONG&gt;needed&lt;/STRONG&gt;?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can think of a few activities I commonly do in which knowing/using variable order is "needed":&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;When displaying the data&lt;/LI&gt;
&lt;LI&gt;Expecting the identifier variables (id/date/time/...) to consistently be in a particular position&lt;/LI&gt;
&lt;LI&gt;Variable clusters - i.e.&amp;nbsp; &amp;nbsp;6 groups of 5 attributes arranged contiguously&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;True, the above are for looking at the data, not programming.&amp;nbsp; But I often take advantage of variable order in programming as well, mostly through use of the double dash as a means of generating a list of variable names or array declarations, typically to avoid listing lots of variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or it can also be useful when I might not actually know the variable names of interest.&amp;nbsp; For example: let's say that I want to interleave A and B, but keep only the variables present in dataset A:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  if 0 then set a;
  retain _sentinel1 .;
  if 0 then set b;
  retain _sentinel2 .;
  set a b;
  by id;
  drop _sentinel1--_sentinel2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Yes, this can be done directly in SQL, but there are often many reasons to use a data step instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Apr 2021 14:09:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-and-re-position-variables-on-same-row-Proc-Transpose/m-p/734877#M228931</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-04-17T14:09:47Z</dc:date>
    </item>
  </channel>
</rss>

