<?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: Sort based on reference column and ID column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/819968#M323629</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/406934"&gt;@osbornejo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I just checked my actual data again and I misspoke - the original entries have a CrossRef of 0, not missing.&amp;nbsp; I think that's what is throwing the coalesce off&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, a zero is not a missing value, so coalesce will not skip over it to look for a subsequent non-missing value.&amp;nbsp; This can be dealt with by some minor code modification.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But possibly more significant you also tell us&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;ID and CrossRef are character variables, not numeric.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Now the coalesce function will automatically convert arguments of entirely numeric characters to actual numeric values, with a note to that effect on your log.&amp;nbsp; This is probably good, because any ID or CROSSREF values of less than 5 digits (forget the "0" for now), will be sorted in numeric order, rather than in lexicographic order if they had remained character.&amp;nbsp; Otherwise "2345" would sort AFTER "12345".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I would stick with the coalesce function, but change the first argument from&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;CROSSREF&lt;/STRONG&gt;&lt;/EM&gt; to &lt;EM&gt;&lt;STRONG&gt;IFC(crossref='0','.',crossref)&lt;/STRONG&gt;&lt;/EM&gt;, allowing a character "0" to be replaced by a ".", and treated by coalesce as a missing value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input ID :$5.	CrossRef :$5.;
cards;
10001	0
10002	0
10003	0
12005	0
12006	10003
12007	10042
13015	10003
;

data need / view=need;
  set have;
  _sortvar=coalesce(ifc(crossref='0','.',crossref),id);
run;
proc sort data=need out=want (drop=_:);
  by _sortvar id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit note: actually the problem of character variables is not entirely solved above.&amp;nbsp; The minor sort key (ID) can cause a problem it you apply the code above to the data below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input ID :$5.	CrossRef :$5.;
cards;
2345    0
10001	0
10002	0
10003	0
12005	0
12006	10003
12007	10042
13015	10003
19999   2345
33333   2345
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The fix would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data need / view=need;
  set have;
  _sortvar=coalesce(ifc(crossref='0','.',crossref),id);
  _sortvar2=right(id);
run;
proc sort data=need out=want (drop=_:);
  by _sortvar _sortvar2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 23 Jun 2022 14:27:10 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2022-06-23T14:27:10Z</dc:date>
    <item>
      <title>Sort based on reference column and ID column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/818938#M323277</link>
      <description>&lt;P&gt;I have a large table that looks something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;CrossRef&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10001&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10002&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10003&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12005&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12006&lt;/TD&gt;&lt;TD&gt;10003&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12007&lt;/TD&gt;&lt;TD&gt;10042&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;13015&lt;/TD&gt;&lt;TD&gt;10003&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any row that is missing a CrossRef is an original entry, and any row with a CrossRef is modifying the row with the matching ID.&amp;nbsp; Larger ID values indicate later entries.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want is to sort this so that the original entry is immediately followed by any that modify it, e.g.:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;CrossRef&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10001&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10002&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10003&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12006&lt;/TD&gt;&lt;TD&gt;10003&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;13015&lt;/TD&gt;&lt;TD&gt;10003&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10005&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10042&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12007&lt;/TD&gt;&lt;TD&gt;10042&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 17 Jun 2022 22:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/818938#M323277</guid>
      <dc:creator>osbornejo</dc:creator>
      <dc:date>2022-06-17T22:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Sort based on reference column and ID column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/818939#M323278</link>
      <description>&lt;P&gt;This does what I understand you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data need / view=need;
  set have;
  _sortvar=coalesce(crossref,id);
run;
proc sort data=need out=want (drop=_:);
  by _sortvar id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Jun 2022 23:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/818939#M323278</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-06-17T23:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: Sort based on reference column and ID column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/819474#M323470</link>
      <description>&lt;P&gt;This almost works - the problem I'm having is that each original entry (e.g. id = 10003) always has a CrossRef of . (i.e. missing), so the coalesce gets confused. What you're doing makes sense though.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 21:53:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/819474#M323470</guid>
      <dc:creator>osbornejo</dc:creator>
      <dc:date>2022-06-21T21:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Sort based on reference column and ID column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/819480#M323475</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/406934"&gt;@osbornejo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;This almost works - the problem I'm having is that each original entry (e.g. id = 10003) always has a CrossRef of . (i.e. missing), so the coalesce gets confused. What you're doing makes sense though.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That does not make sense.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Try it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input ID	CrossRef ;
cards;
10001	.
10002	.
10003	.
12005	.
12006	10003
12007	10042
13015	10003
;

data step1;
  set have;
  orig_id = coalesce(crossref,id);
run;

proc sort;
  by orig_id id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;                Cross
Obs      ID      Ref     orig_id

 1     10001        .     10001
 2     10002        .     10002
 3     10003        .     10003
 4     12006    10003     10003
 5     13015    10003     10003
 6     12007    10042     10042
 7     12005        .     12005
&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jun 2022 23:04:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/819480#M323475</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-21T23:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Sort based on reference column and ID column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/819481#M323476</link>
      <description>&lt;P&gt;Is the issue that the CROSS_REF is not to the ORIGINAL id but to just the PREVIOUS id?&amp;nbsp; Which might have itself been a CROSS_REF before?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 23:07:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/819481#M323476</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-21T23:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Sort based on reference column and ID column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/819629#M323531</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/406934"&gt;@osbornejo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;This almost works - the problem I'm having is that each original entry (e.g. id = 10003) always has a CrossRef of . (i.e. missing), so the coalesce gets confused. What you're doing makes sense though.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The task is "&lt;SPAN&gt;What I want is to sort this so that the original entry is immediately followed by any that modify it,".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;which is what happens in the code I provided, given that "larger ID values indicate later entries.".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would need some additional e&lt;SPAN&gt;xplanation of what you want, and some sample data and desired results in which the submitted code produces different results.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 14:06:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/819629#M323531</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-06-22T14:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: Sort based on reference column and ID column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/819640#M323533</link>
      <description>&lt;P&gt;I just checked my actual data again and I misspoke - the original entries have a CrossRef of 0, not missing.&amp;nbsp; I think that's what is throwing the sort off, because when I tried it, I ended up with&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Obs      ID      CrossRef orig_id

 1     10001        0     0
 2     10002        0     0
 3     10003        0     0
 4     12005        0     0
 5     12006    10003     10003
 6     13015    10003     10003
 7     12007    10042     10042&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, ID and CrossRef are character variables, not numeric.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 14:41:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/819640#M323533</guid>
      <dc:creator>osbornejo</dc:creator>
      <dc:date>2022-06-22T14:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: Sort based on reference column and ID column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/819641#M323534</link>
      <description>&lt;P&gt;I just checked my actual data again and I misspoke - the original entries have a CrossRef of 0, not missing.&amp;nbsp; I think that's what is throwing the coalesce off, because when I tried it, I ended up with&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Obs      ID      CrossRef orig_id

 1     10001        0     0
 2     10002        0     0
 3     10003        0     0
 4     12005        0     0
 5     12006    10003     10003
 6     13015    10003     10003
 7     12007    10042     10042&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, ID and CrossRef are character variables, not numeric.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 14:42:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/819641#M323534</guid>
      <dc:creator>osbornejo</dc:creator>
      <dc:date>2022-06-22T14:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: Sort based on reference column and ID column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/819968#M323629</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/406934"&gt;@osbornejo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I just checked my actual data again and I misspoke - the original entries have a CrossRef of 0, not missing.&amp;nbsp; I think that's what is throwing the coalesce off&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, a zero is not a missing value, so coalesce will not skip over it to look for a subsequent non-missing value.&amp;nbsp; This can be dealt with by some minor code modification.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But possibly more significant you also tell us&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;ID and CrossRef are character variables, not numeric.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Now the coalesce function will automatically convert arguments of entirely numeric characters to actual numeric values, with a note to that effect on your log.&amp;nbsp; This is probably good, because any ID or CROSSREF values of less than 5 digits (forget the "0" for now), will be sorted in numeric order, rather than in lexicographic order if they had remained character.&amp;nbsp; Otherwise "2345" would sort AFTER "12345".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I would stick with the coalesce function, but change the first argument from&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;CROSSREF&lt;/STRONG&gt;&lt;/EM&gt; to &lt;EM&gt;&lt;STRONG&gt;IFC(crossref='0','.',crossref)&lt;/STRONG&gt;&lt;/EM&gt;, allowing a character "0" to be replaced by a ".", and treated by coalesce as a missing value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input ID :$5.	CrossRef :$5.;
cards;
10001	0
10002	0
10003	0
12005	0
12006	10003
12007	10042
13015	10003
;

data need / view=need;
  set have;
  _sortvar=coalesce(ifc(crossref='0','.',crossref),id);
run;
proc sort data=need out=want (drop=_:);
  by _sortvar id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit note: actually the problem of character variables is not entirely solved above.&amp;nbsp; The minor sort key (ID) can cause a problem it you apply the code above to the data below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input ID :$5.	CrossRef :$5.;
cards;
2345    0
10001	0
10002	0
10003	0
12005	0
12006	10003
12007	10042
13015	10003
19999   2345
33333   2345
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The fix would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data need / view=need;
  set have;
  _sortvar=coalesce(ifc(crossref='0','.',crossref),id);
  _sortvar2=right(id);
run;
proc sort data=need out=want (drop=_:);
  by _sortvar _sortvar2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jun 2022 14:27:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/819968#M323629</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-06-23T14:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: Sort based on reference column and ID column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/820059#M323657</link>
      <description>Ok, I tried this and when I look at _sortvar in the need table, it is equal to . when the CrossRef is 0.  I don't understand why that is happening - I thought coalesce() was supposed to skip missing values.  Does the period work as a missing value when it is a character variable?</description>
      <pubDate>Thu, 23 Jun 2022 16:17:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/820059#M323657</guid>
      <dc:creator>osbornejo</dc:creator>
      <dc:date>2022-06-23T16:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: Sort based on reference column and ID column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/820061#M323658</link>
      <description>&lt;P&gt;Only strings that contain all spaces will be treated as missing.&amp;nbsp; Perhaps you are confused because the normal character informat $ will convert '.' into ' '.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 16:21:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/820061#M323658</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-23T16:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: Sort based on reference column and ID column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/820131#M323678</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/406934"&gt;@osbornejo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Ok, I tried this and when I look at _sortvar in the need table, it is equal to . when the CrossRef is 0. I don't understand why that is happening - I thought coalesce() was supposed to skip missing values. Does the period work as a missing value when it is a character variable?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If CrossRef="0" then the only time _sortvar should be missing is when ID has a non-numeric character or is completely blank.&amp;nbsp; And in that case there would be an error message on your SAS log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I can't respond usefully to this result without relevant information.&amp;nbsp; Please provide (1) the original data of the offending observations, and (2) the log of the data step that generated the _sortvar=. result.&amp;nbsp; &amp;nbsp; Otherwise, I am unable to reproduce the problem you describe.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 18:56:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/820131#M323678</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-06-23T18:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Sort based on reference column and ID column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/820136#M323679</link>
      <description>Unfortunately I can't provide the original data as it contains sensitive/identifiable information.  However, I was able to get your code to work by replacing '.' in the ifc() with '' (empty string).  My thanks to you and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; for your help!</description>
      <pubDate>Thu, 23 Jun 2022 19:10:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-based-on-reference-column-and-ID-column/m-p/820136#M323679</guid>
      <dc:creator>osbornejo</dc:creator>
      <dc:date>2022-06-23T19:10:08Z</dc:date>
    </item>
  </channel>
</rss>

