<?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 Sort add a number between whole numbers for sort order in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sort-add-a-number-between-whole-numbers-for-sort-order/m-p/781277#M249008</link>
    <description>&lt;P&gt;How many values are involved? Are the values constant or do you have lots of changes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It might be that you could make a custom INFORMAT to create a numeric value that could use to sort with.&lt;/P&gt;
&lt;P&gt;A brief example:&lt;/P&gt;
&lt;PRE&gt;data example;
   input value $;
datalines  ;
abc
451
8rtq 
blue3
;

proc format;
  invalue sortord
'451' = 1
'blue3' = 2
'abc'   = 3
'8rtq'  = 4
;
run;

data need;
   set example;
   order = input (value,sortord.);
run;

proc sort data=need;
  by order;
run;&lt;/PRE&gt;
&lt;P&gt;But I'm not sure how "100 fields" applies. Are you saying that you are going to sort on 100 variables???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you need to provide a much more complete example of data and what the final result would be. Probably only 5 or so variables and enough records to demonstrate typical needed behavior.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Nov 2021 15:11:00 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-11-19T15:11:00Z</dc:date>
    <item>
      <title>Proc Sort add a number between whole numbers for sort order</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sort-add-a-number-between-whole-numbers-for-sort-order/m-p/781262#M249003</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to sort my output and am not sure how to insert a few lines in the right place, without re-ordering everything (if possible).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically it looks like this, as an example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;blue - 01&lt;/P&gt;&lt;P&gt;red-02&lt;/P&gt;&lt;P&gt;purple- 03&lt;/P&gt;&lt;P&gt;orange- 04&lt;/P&gt;&lt;P&gt;grey-05&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These fields are numbered up to 100, with a code that already existed and are in the correct order. However between lets say blue 01 and red 02, I would like to add an additional field (for example green) so it would come after blue and before red. Is there a number I can assign to green, so that it will be listed after red and before purple. For example would 02.1 work, or is there a way to insert without messing up the other fields? There are basically 100 fields that are assigned codes in order, but I need to insert about 5 in certain places. Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 14:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sort-add-a-number-between-whole-numbers-for-sort-order/m-p/781262#M249003</guid>
      <dc:creator>sashelp123</dc:creator>
      <dc:date>2021-11-19T14:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sort add a number between whole numbers for sort order</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sort-add-a-number-between-whole-numbers-for-sort-order/m-p/781264#M249005</link>
      <description>&lt;P&gt;Sorting of character strings works alphabetically. The way you have set this up (for the five shown) blue is always first and grey is always second and changing the number to the right of the color will not affect sorting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorting of numeric variables works numerically. What you need to do is to create the proper numeric variable containing the sort order for each row, and then your sorts will work the way you want.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 14:46:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sort-add-a-number-between-whole-numbers-for-sort-order/m-p/781264#M249005</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-19T14:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sort add a number between whole numbers for sort order</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sort-add-a-number-between-whole-numbers-for-sort-order/m-p/781269#M249006</link>
      <description>&lt;P&gt;Ok thank you! these were just examples that happened to be alphabetical unfortunately. But basically they each already have a number code assigned (over 100 varabiles) and are in the proper order, so I was hoping for the five I had to fit in, there was a way to add a number between whole numbers. Like if 04 is followed by 05, would there be a number I could assign to stick it between 04 and 05 and avoid re-ordering all 100? Sorry if I am not making sense, I appreciate the help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 14:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sort-add-a-number-between-whole-numbers-for-sort-order/m-p/781269#M249006</guid>
      <dc:creator>sashelp123</dc:creator>
      <dc:date>2021-11-19T14:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sort add a number between whole numbers for sort order</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sort-add-a-number-between-whole-numbers-for-sort-order/m-p/781270#M249007</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Like if 04 is followed by 05&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;04 is a character string.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming you have a numeric variable (do you?) then if you have numbers 4 and 5, then 4.5 will sort between them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 14:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sort-add-a-number-between-whole-numbers-for-sort-order/m-p/781270#M249007</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-19T14:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sort add a number between whole numbers for sort order</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sort-add-a-number-between-whole-numbers-for-sort-order/m-p/781277#M249008</link>
      <description>&lt;P&gt;How many values are involved? Are the values constant or do you have lots of changes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It might be that you could make a custom INFORMAT to create a numeric value that could use to sort with.&lt;/P&gt;
&lt;P&gt;A brief example:&lt;/P&gt;
&lt;PRE&gt;data example;
   input value $;
datalines  ;
abc
451
8rtq 
blue3
;

proc format;
  invalue sortord
'451' = 1
'blue3' = 2
'abc'   = 3
'8rtq'  = 4
;
run;

data need;
   set example;
   order = input (value,sortord.);
run;

proc sort data=need;
  by order;
run;&lt;/PRE&gt;
&lt;P&gt;But I'm not sure how "100 fields" applies. Are you saying that you are going to sort on 100 variables???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you need to provide a much more complete example of data and what the final result would be. Probably only 5 or so variables and enough records to demonstrate typical needed behavior.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 15:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sort-add-a-number-between-whole-numbers-for-sort-order/m-p/781277#M249008</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-19T15:11:00Z</dc:date>
    </item>
  </channel>
</rss>

