<?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: Custom Sorting in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/540892#M149262</link>
    <description>&lt;P&gt;I have no clue on how to create and use a hash sadly.&lt;BR /&gt;&lt;BR /&gt;I will try the proc sql merge and let you know&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Mar 2019 19:14:59 GMT</pubDate>
    <dc:creator>Pabster</dc:creator>
    <dc:date>2019-03-06T19:14:59Z</dc:date>
    <item>
      <title>Custom Sorting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/540859#M149251</link>
      <description>&lt;P&gt;Hi ,&lt;BR /&gt;&lt;BR /&gt;I have two data sets derived from the same original set:&lt;BR /&gt;&lt;BR /&gt;A) Which is where I have managed to sort companies by their respective SIC CODE and GVKEY with a variable horizon input. The Variable give me the opportunity to change how many years prior bankruptcy(or the last data available for non bankrupt firms) I want to see.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Unsorted_With_horizon.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27708iE2EC9448DC8C2939/image-size/large?v=v2&amp;amp;px=999" role="button" title="Unsorted_With_horizon.png" alt="Unsorted_With_horizon.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;B) Another data set I created. This one only contains the last input of each company. It is sorted by year and sector. The way it sorted let me make comparisons between a bankrupt firm (costat=1) and a nonbankrupt one (Costaty=0) from the same industry at a precise year.&amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;That`s the way I want to see it BUT with the horizon variable that let s me check year prior the bankruptcy&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Last_GVKEY-Sorted.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27709i521E0AD3E092FF19/image-size/large?v=v2&amp;amp;px=999" role="button" title="Last_GVKEY-Sorted.png" alt="Last_GVKEY-Sorted.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is :&lt;BR /&gt;&lt;BR /&gt;IS there any way I can tell sas to keep the same order from the b) dataset and put that order in the A) data set. I would probably have to be with the GVKEYS I suppose&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 18:23:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/540859#M149251</guid>
      <dc:creator>Pabster</dc:creator>
      <dc:date>2019-03-06T18:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Sorting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/540861#M149252</link>
      <description>&lt;P&gt;Your comment&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;STRONG&gt;That`s the way I want to see it BUT with the horizon variable that let s me check year prior the bankruptcy&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;makes me think you should just pull the horizon variable from your A) table into your B) table. Is that possible for you using proc sql or another join?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 18:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/540861#M149252</guid>
      <dc:creator>noling</dc:creator>
      <dc:date>2019-03-06T18:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Sorting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/540865#M149253</link>
      <description>&lt;P&gt;*UPDATE*&lt;BR /&gt;&lt;BR /&gt;I Took out the order from the B) data set with this code:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;data Order;
set B);
order=_N_;
keep gvkey order;
run;&lt;/PRE&gt;&lt;P&gt;but now when I merge it with the A data set the order from the A is unchanged...&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 18:47:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/540865#M149253</guid>
      <dc:creator>Pabster</dc:creator>
      <dc:date>2019-03-06T18:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Sorting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/540867#M149254</link>
      <description>&lt;P&gt;Yeah that`s pretty much how I ended up with the A data set but the order is messed up now&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 18:41:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/540867#M149254</guid>
      <dc:creator>Pabster</dc:creator>
      <dc:date>2019-03-06T18:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Sorting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/540876#M149257</link>
      <description>&lt;P&gt;You could:&lt;/P&gt;&lt;P&gt;1. Use a data step and SET table B. Load table A into a hash, and pull in the desired field.&lt;/P&gt;&lt;P&gt;2. (looks like you're trying this) Create a new var on Table B with is = _N_, then proc sql and LEFT JOIN table A to table B (table B on left), then sort the new table by your new _N_ variable&lt;/P&gt;&lt;P&gt;3. A data step merge would probably also work if you can sort both tables, and have table A only have your key and desired field&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do those options make sense?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 18:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/540876#M149257</guid>
      <dc:creator>noling</dc:creator>
      <dc:date>2019-03-06T18:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Sorting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/540892#M149262</link>
      <description>&lt;P&gt;I have no clue on how to create and use a hash sadly.&lt;BR /&gt;&lt;BR /&gt;I will try the proc sql merge and let you know&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 19:14:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/540892#M149262</guid>
      <dc:creator>Pabster</dc:creator>
      <dc:date>2019-03-06T19:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Sorting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/540914#M149274</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/115150"&gt;@noling&lt;/a&gt;. cant manage to make it work</description>
      <pubDate>Wed, 06 Mar 2019 20:16:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/540914#M149274</guid>
      <dc:creator>Pabster</dc:creator>
      <dc:date>2019-03-06T20:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Sorting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/541080#M149354</link>
      <description>&lt;P&gt;Does this approach make sense? Let's say that in this case we want to pull MAKE from table A into table B, and maintain table B's order. The key in this case is MODEL:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A ;
	set sashelp.cars(obs=10);
	keep make model;
run;
data B;
	set sashelp.cars(obs=10);
	keep msrp model ob_no;
	ob_no=_N_;
run;

*want to pull the make value from table A into table B, and maintain table B's order;
proc sql noprint;
	create table want(drop=ob_no) as
	select B.*, make
	from B left join
		A on B.model =A.model
	order by ob_no;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Mar 2019 13:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/541080#M149354</guid>
      <dc:creator>noling</dc:creator>
      <dc:date>2019-03-07T13:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Sorting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/541099#M149362</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/261982"&gt;@Pabster&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Yeah that`s pretty much how I ended up with the A data set but the order is messed up now&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The order of variables is hardly relevant for anything, except proc export.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 14:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/541099#M149362</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-03-07T14:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Sorting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/541113#M149368</link>
      <description>My supervisor has asked me to give it to him in a specific way. and it is kind of relevant for the research</description>
      <pubDate>Thu, 07 Mar 2019 15:12:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/541113#M149368</guid>
      <dc:creator>Pabster</dc:creator>
      <dc:date>2019-03-07T15:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Sorting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/541114#M149369</link>
      <description>I got 2000 less observation on my A dataset now but it indeed works !</description>
      <pubDate>Thu, 07 Mar 2019 15:13:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Custom-Sorting/m-p/541114#M149369</guid>
      <dc:creator>Pabster</dc:creator>
      <dc:date>2019-03-07T15:13:23Z</dc:date>
    </item>
  </channel>
</rss>

