<?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: proc sql sorting values unexpectedly. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481585#M286774</link>
    <description>Never seen that happen. Please post your full code.</description>
    <pubDate>Thu, 26 Jul 2018 16:29:31 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-07-26T16:29:31Z</dc:date>
    <item>
      <title>proc sql sorting values unexpectedly.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481582#M286773</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just a quick question on the use of proc sql. I am trying to create the data set below. It is a list of variables from one of the tables I work with (original table contains 50variables). I have used a data set with an infile statement to create this, saving it in a permanent library. However, when it gets saved in a permanent library, the ordering of the&amp;nbsp;values change, and get sorted in ascending order. However, I have noticed that when a temporary table is created instead with data and infile statements, it is sorted as expected.&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="Screen Shot 2018-07-26 at 17.19.43.png" style="width: 562px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22049iD2A519D6D8838EAC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2018-07-26 at 17.19.43.png" alt="Screen Shot 2018-07-26 at 17.19.43.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;source code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Axis.Field_names;&lt;BR /&gt;length Variables $25;&lt;BR /&gt;input Variables $;&lt;BR /&gt;cards;&lt;BR /&gt;Tenure&lt;BR /&gt;Age&lt;BR /&gt;Household_Income&lt;BR /&gt;Family_Size&lt;BR /&gt;Monthly_Rents&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I save it in a permanent location without altering the ordering of the values?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 16:27:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481582#M286773</guid>
      <dc:creator>frupaul</dc:creator>
      <dc:date>2018-07-26T16:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql sorting values unexpectedly.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481585#M286774</link>
      <description>Never seen that happen. Please post your full code.</description>
      <pubDate>Thu, 26 Jul 2018 16:29:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481585#M286774</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-26T16:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql sorting values unexpectedly.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481587#M286775</link>
      <description>&lt;P&gt;Something must be changing the order. Perhaps you saved it into something other than a SAS dataset?&amp;nbsp; Like a external database?&lt;/P&gt;
&lt;P&gt;Perhaps the way you are viewing/printing the value is sorting them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to preserve the original order then you should create a variable that does that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Axis.Field_names;
  length Varnum 8 Variable $25;
  Varnum+1;
  input Variable $;
cards;
Tenure
Age
Household_Income
Family_Size
Monthly_Rents
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jul 2018 16:33:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481587#M286775</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-26T16:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql sorting values unexpectedly.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481588#M286776</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code is posted in initial Message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I use data statement- Data temporary_table - it arranges the values as expected.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i use datastatement - Date permanant_table - it stores them in a permanent table and rearranges values alphabetically.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 16:34:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481588#M286776</guid>
      <dc:creator>frupaul</dc:creator>
      <dc:date>2018-07-26T16:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql sorting values unexpectedly.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481589#M286777</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134464"&gt;@frupaul&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code is posted in initial Message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I use data statement- Data temporary_table - it arranges the values as expected.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When i use datastatement - Date permanant_table - it stores them in a permanent table and rearranges values alphabetically.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your title says PROC SQL and I don't see any PROC SQL code in this thread.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 16:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481589#M286777</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-26T16:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql sorting values unexpectedly.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481590#M286778</link>
      <description>If these are variable values then there is no order enforced and SQL does not guarantee to maintain any order. If these are variable names of a data set they will remain in order. SASHELP.VCOLUMN has a list of all the variable names/labels/types that can be used for these types of exercises including a variable Number to help with ordering exercises. If you need a specific order of variable values you have to enforce it with a sort, though a data step will not change the order AFAIK.</description>
      <pubDate>Thu, 26 Jul 2018 16:37:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481590#M286778</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-26T16:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql sorting values unexpectedly.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481592#M286779</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134464"&gt;@frupaul&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code is posted in initial Message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I use data statement- Data temporary_table - it arranges the values as expected.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When i use datastatement - Date permanant_table - it stores them in a permanent table and rearranges values alphabetically.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;NO.WAY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the internal order of variables in the dataset is kept as is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you think differently, post your WHOLE code you are using to create the permanent table.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 16:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481592#M286779</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-26T16:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql sorting values unexpectedly.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481594#M286780</link>
      <description>&lt;P&gt;Run this and post the output.&amp;nbsp;&lt;BR /&gt;If what you're saying is happening, the compare will not be equal. Otherwise, you have some other issue.&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;

libname demo 'C:\_localdata\temp\';

data demo.class;
set class;
run;

proc sql;
create table demo.class2 as
select *
from class;
quit;

proc compare data=demo.class compare=demo.class2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jul 2018 16:53:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-sorting-values-unexpectedly/m-p/481594#M286780</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-26T16:53:54Z</dc:date>
    </item>
  </channel>
</rss>

