<?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 Can I use proc sql to dynamically merge two datasets? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365794#M86926</link>
    <description>&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;Good afternoon and happy Friday, folks&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;I’m trying to automate a placement simulation of youth into residential treatment where they will have the highest likelihood of success. Success is operationalized as “not recidivating” within 3 years of entering treatment. Equations predicting recidivism have been generated for each location, and the equations have been applied to each individual in the scenario (based on youth characteristics like risk, age, etc., LOS). Each youth has predicted success rates for every location, which throws in a wrench: youth are not qualified for all of the treatment facilities for which they have predicted success rates. Indeed, treatment locations have differing, yet overlapping qualifications. Let’s take a made-up example. Johnny (ID # 5, below) is a 15-year-old boy with drug charges. He could have “predicted success rates” of 91% for location A, 88% for location B, 50% for location C, and 75% for location D. Johnny is most likely to be successful (i.e., not recidivate within three years of entering treatment) if he is treated at location A; unfortunately, location A only accepts youth who are 17 years old or older; therefore, Johnny would not qualify for treatment here. Alternatively, for Johnny, location B is the next best location. Let us assume that Johnny is qualified for location B, but that all of location-B beds are filled; so, we must now look to location D, as it is now Johnny’s “best available” option at 75%. The score so far: We are matching youth to available beds in location for which they qualify and might enjoy the greatest likelihood of success. Unfortunately, each location only has a certain number of available beds, and the number of available beds different across locations. The qualifications of entry into treatment facilities differ, yet overlap (e.g., 12-17 year-olds vs 14-20 year-olds). In order to simulate what placement decisions might look like based on success rates, I went through the scenario describe above for over 400 youth, by hand, in excel. It took me about a week. I’d like to use PROC SQL imbedded in a SAS MACRO to automate these placement scenarios with the ultimate goals of a) obtain the ability to bootstrap iterations in order to examine effect sizes across distributions, b) save time, and c) prevent further brain damage from banging my head again desk and wall in frustration whilst doing this by hand. Whilst never having had the necessity—nay—the privilege of using SQL in my typical roll as a researcher, I believe that this time has now come to pass and I’m excited about it! Honestly. I believe it has the capacity I’m looking for. Unfortunately, it is beating the devil out of me! Here’s what I’ve got cookin’ so far: I want to create and automate the placement simulation with the clever use of merging/joining/switching/or something like that. I have two datasets (tables). The first dataset contains all of the youth information (one row per youth; several columns with demographics, location ranks, which correspond to the predicted success rates). The order of rows in the youth dataset (was/will be randomly generated (to simulate the randomness with which youth enter the system and are subsequently place into treatment). Note that I will be “cleaning” the youth dataset prior to merging such that rank-column cells will only be populated for programs for which a respective youth qualifies. This should take the “does the youth even qualify for the program” problem out of the equation.&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;However, it still leaves the issue of availability left to be contended with in the scenario. The second dataset containing the treatment facility beds, with each row corresponding to an available bed in one of the treatment location; two columns contain bed numbers and location names. Each bed (row) has only one location cell populated, but locations will populate several cells.&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;Thus, in descending order, I want to merge each youth row with the available bed that represents his/her best chance of success, and so the merge/join/switch/thing should take place&lt;/P&gt;
&lt;PRE class="lang-sql prettyprint prettyprinted" style="margin: 0px 0px 1em; padding: 5px; border: 0px currentColor; border-image: none; width: auto; text-align: left; color: rgb(57, 51, 24); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; overflow: auto; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; display: block; -ms-word-wrap: normal; max-height: 600px; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(239, 240, 241); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;&lt;CODE style="margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; line-height: inherit; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-style: inherit; font-variant: inherit; font-weight: inherit; vertical-align: baseline; white-space: inherit; font-stretch: inherit; background-color: rgb(239, 240, 241);"&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;on&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; youth&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Rank1&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;=&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;distinct&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; TF&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Location&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;,&lt;/SPAN&gt; 
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;and&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;if&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; youth&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Rank1&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;≠&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; TF&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;location &lt;/SPAN&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;then&lt;/SPAN&gt; 
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;merge&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;on&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; youth&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Rank2&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; TF&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;location&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;,&lt;/SPAN&gt; 
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;if&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; youth&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Rank2&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;≠&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; TF&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;location &lt;/SPAN&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;then&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;merge&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; at 
youth&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Rank3 &lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; TF&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;location&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; etc&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;Put plainly: “Merge on rank1 unless rank1 location is no longer available, then merge on rank2, unless rank2 location is no longer available, and on down the line, etc., etc., until all option are exhausted and foster care (i.e., alternative services). Is the only option.&lt;BR /&gt;I’ve had no success getting this to work. I haven’t even been successful getting the union function to work. About the only successful thing I’ve done in SQL so far is create a view of a single dataset. It’s pretty sad. I’ve been following this guidance, but I get hung up around the “where” command:&lt;/P&gt;
&lt;PRE class="lang-sql prettyprint prettyprinted" style="margin: 0px 0px 1em; padding: 5px; border: 0px currentColor; border-image: none; width: auto; text-align: left; color: rgb(57, 51, 24); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; overflow: auto; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; display: block; -ms-word-wrap: normal; max-height: 600px; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(239, 240, 241); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;&lt;CODE style="margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; line-height: inherit; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-style: inherit; font-variant: inherit; font-weight: inherit; vertical-align: baseline; white-space: inherit; font-stretch: inherit; background-color: rgb(239, 240, 241);"&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;proc&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; sql&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;;&lt;/SPAN&gt; &lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Calls the SQL &lt;/SPAN&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;procedure&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;*/;&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;create&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;table&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; x &lt;/SPAN&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;as&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Tells SAS to create a table called x*/&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;select&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Specifies the column(s) to be selected*/&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;from&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Specificies the tables(s) (data sets) to be queried*/&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;where&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Subjests the data based on a condition*/&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;group&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;by&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Classifies the data into groups based on the specified 
column(s)*/&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;order&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;by&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Sorts the resulting rows observations) by the specified 
column(s)*/&lt;/SPAN&gt;
&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;;&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; quit&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;;&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Ends the proc sql procedure*/&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;Frankly, I’m stuck and I could use some advice. This greenhorn in me is in way over his head.&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;I appreciate any help or guidance anyone might lend.&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;Cheers!&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;P&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2017 19:07:29 GMT</pubDate>
    <dc:creator>PhilG</dc:creator>
    <dc:date>2017-06-09T19:07:29Z</dc:date>
    <item>
      <title>Can I use proc sql to dynamically merge two datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365794#M86926</link>
      <description>&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;Good afternoon and happy Friday, folks&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;I’m trying to automate a placement simulation of youth into residential treatment where they will have the highest likelihood of success. Success is operationalized as “not recidivating” within 3 years of entering treatment. Equations predicting recidivism have been generated for each location, and the equations have been applied to each individual in the scenario (based on youth characteristics like risk, age, etc., LOS). Each youth has predicted success rates for every location, which throws in a wrench: youth are not qualified for all of the treatment facilities for which they have predicted success rates. Indeed, treatment locations have differing, yet overlapping qualifications. Let’s take a made-up example. Johnny (ID # 5, below) is a 15-year-old boy with drug charges. He could have “predicted success rates” of 91% for location A, 88% for location B, 50% for location C, and 75% for location D. Johnny is most likely to be successful (i.e., not recidivate within three years of entering treatment) if he is treated at location A; unfortunately, location A only accepts youth who are 17 years old or older; therefore, Johnny would not qualify for treatment here. Alternatively, for Johnny, location B is the next best location. Let us assume that Johnny is qualified for location B, but that all of location-B beds are filled; so, we must now look to location D, as it is now Johnny’s “best available” option at 75%. The score so far: We are matching youth to available beds in location for which they qualify and might enjoy the greatest likelihood of success. Unfortunately, each location only has a certain number of available beds, and the number of available beds different across locations. The qualifications of entry into treatment facilities differ, yet overlap (e.g., 12-17 year-olds vs 14-20 year-olds). In order to simulate what placement decisions might look like based on success rates, I went through the scenario describe above for over 400 youth, by hand, in excel. It took me about a week. I’d like to use PROC SQL imbedded in a SAS MACRO to automate these placement scenarios with the ultimate goals of a) obtain the ability to bootstrap iterations in order to examine effect sizes across distributions, b) save time, and c) prevent further brain damage from banging my head again desk and wall in frustration whilst doing this by hand. Whilst never having had the necessity—nay—the privilege of using SQL in my typical roll as a researcher, I believe that this time has now come to pass and I’m excited about it! Honestly. I believe it has the capacity I’m looking for. Unfortunately, it is beating the devil out of me! Here’s what I’ve got cookin’ so far: I want to create and automate the placement simulation with the clever use of merging/joining/switching/or something like that. I have two datasets (tables). The first dataset contains all of the youth information (one row per youth; several columns with demographics, location ranks, which correspond to the predicted success rates). The order of rows in the youth dataset (was/will be randomly generated (to simulate the randomness with which youth enter the system and are subsequently place into treatment). Note that I will be “cleaning” the youth dataset prior to merging such that rank-column cells will only be populated for programs for which a respective youth qualifies. This should take the “does the youth even qualify for the program” problem out of the equation.&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;However, it still leaves the issue of availability left to be contended with in the scenario. The second dataset containing the treatment facility beds, with each row corresponding to an available bed in one of the treatment location; two columns contain bed numbers and location names. Each bed (row) has only one location cell populated, but locations will populate several cells.&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;Thus, in descending order, I want to merge each youth row with the available bed that represents his/her best chance of success, and so the merge/join/switch/thing should take place&lt;/P&gt;
&lt;PRE class="lang-sql prettyprint prettyprinted" style="margin: 0px 0px 1em; padding: 5px; border: 0px currentColor; border-image: none; width: auto; text-align: left; color: rgb(57, 51, 24); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; overflow: auto; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; display: block; -ms-word-wrap: normal; max-height: 600px; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(239, 240, 241); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;&lt;CODE style="margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; line-height: inherit; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-style: inherit; font-variant: inherit; font-weight: inherit; vertical-align: baseline; white-space: inherit; font-stretch: inherit; background-color: rgb(239, 240, 241);"&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;on&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; youth&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Rank1&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;=&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;distinct&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; TF&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Location&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;,&lt;/SPAN&gt; 
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;and&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;if&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; youth&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Rank1&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;≠&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; TF&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;location &lt;/SPAN&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;then&lt;/SPAN&gt; 
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;merge&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;on&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; youth&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Rank2&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; TF&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;location&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;,&lt;/SPAN&gt; 
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;if&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; youth&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Rank2&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;≠&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; TF&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;location &lt;/SPAN&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;then&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;merge&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; at 
youth&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Rank3 &lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; TF&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;location&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; etc&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;Put plainly: “Merge on rank1 unless rank1 location is no longer available, then merge on rank2, unless rank2 location is no longer available, and on down the line, etc., etc., until all option are exhausted and foster care (i.e., alternative services). Is the only option.&lt;BR /&gt;I’ve had no success getting this to work. I haven’t even been successful getting the union function to work. About the only successful thing I’ve done in SQL so far is create a view of a single dataset. It’s pretty sad. I’ve been following this guidance, but I get hung up around the “where” command:&lt;/P&gt;
&lt;PRE class="lang-sql prettyprint prettyprinted" style="margin: 0px 0px 1em; padding: 5px; border: 0px currentColor; border-image: none; width: auto; text-align: left; color: rgb(57, 51, 24); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; overflow: auto; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; display: block; -ms-word-wrap: normal; max-height: 600px; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(239, 240, 241); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;&lt;CODE style="margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; line-height: inherit; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-style: inherit; font-variant: inherit; font-weight: inherit; vertical-align: baseline; white-space: inherit; font-stretch: inherit; background-color: rgb(239, 240, 241);"&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;proc&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; sql&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;;&lt;/SPAN&gt; &lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Calls the SQL &lt;/SPAN&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;procedure&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;*/;&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;create&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;table&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; x &lt;/SPAN&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;as&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Tells SAS to create a table called x*/&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;select&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Specifies the column(s) to be selected*/&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;from&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Specificies the tables(s) (data sets) to be queried*/&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;where&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Subjests the data based on a condition*/&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;group&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;by&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Classifies the data into groups based on the specified 
column(s)*/&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;order&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;by&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Sorts the resulting rows observations) by the specified 
column(s)*/&lt;/SPAN&gt;
&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;;&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; quit&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;;&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Ends the proc sql procedure*/&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;Frankly, I’m stuck and I could use some advice. This greenhorn in me is in way over his head.&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;I appreciate any help or guidance anyone might lend.&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;Cheers!&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;P&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 19:07:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365794#M86926</guid>
      <dc:creator>PhilG</dc:creator>
      <dc:date>2017-06-09T19:07:29Z</dc:date>
    </item>
    <item>
      <title>Can I use proc sql  to dynamically merge two dataset in order to simulate placement decisions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365792#M86929</link>
      <description>&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;Good afternoon and happy Friday, folks&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;I’m trying to automate a placement simulation of youth into residential treatment where they will have the highest likelihood of success. Success is operationalized as “not recidivating” within 3 years of entering treatment. Equations predicting recidivism have been generated for each location, and the equations have been applied to each individual in the scenario (based on youth characteristics like risk, age, etc., LOS). Each youth has predicted success rates for every location, which throws in a wrench: youth are not qualified for all of the treatment facilities for which they have predicted success rates. Indeed, treatment locations have differing, yet overlapping qualifications. Let’s take a made-up example. Johnny (ID # 5, below) is a 15-year-old boy with drug charges. He could have “predicted success rates” of 91% for location A, 88% for location B, 50% for location C, and 75% for location D. Johnny is most likely to be successful (i.e., not recidivate within three years of entering treatment) if he is treated at location A; unfortunately, location A only accepts youth who are 17 years old or older; therefore, Johnny would not qualify for treatment here. Alternatively, for Johnny, location B is the next best location. Let us assume that Johnny is qualified for location B, but that all of location-B beds are filled; so, we must now look to location D, as it is now Johnny’s “best available” option at 75%. The score so far: We are matching youth to available beds in location for which they qualify and might enjoy the greatest likelihood of success. Unfortunately, each location only has a certain number of available beds, and the number of available beds different across locations. The qualifications of entry into treatment facilities differ, yet overlap (e.g., 12-17 year-olds vs 14-20 year-olds). In order to simulate what placement decisions might look like based on success rates, I went through the scenario describe above for over 400 youth, by hand, in excel. It took me about a week. I’d like to use PROC SQL imbedded in a SAS MACRO to automate these placement scenarios with the ultimate goals of a) obtain the ability to bootstrap iterations in order to examine effect sizes across distributions, b) save time, and c) prevent further brain damage from banging my head again desk and wall in frustration whilst doing this by hand. Whilst never having had the necessity—nay—the privilege of using SQL in my typical roll as a researcher, I believe that this time has now come to pass and I’m excited about it! Honestly. I believe it has the capacity I’m looking for. Unfortunately, it is beating the devil out of me! Here’s what I’ve got cookin’ so far: I want to create and automate the placement simulation with the clever use of merging/joining/switching/or something like that. I have two datasets (tables). The first dataset contains all of the youth information (one row per youth; several columns with demographics, location ranks, which correspond to the predicted success rates). The order of rows in the youth dataset (was/will be randomly generated (to simulate the randomness with which youth enter the system and are subsequently place into treatment). Note that I will be “cleaning” the youth dataset prior to merging such that rank-column cells will only be populated for programs for which a respective youth qualifies. This should take the “does the youth even qualify for the program” problem out of the equation.&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;However, it still leaves the issue of availability left to be contended with in the scenario. The second dataset containing the treatment facility beds, with each row corresponding to an available bed in one of the treatment location; two columns contain bed numbers and location names. Each bed (row) has only one location cell populated, but locations will populate several cells.&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;Thus, in descending order, I want to merge each youth row with the available bed that represents his/her best chance of success, and so the merge/join/switch/thing should take place&lt;/P&gt;
&lt;PRE class="lang-sql prettyprint prettyprinted" style="margin: 0px 0px 1em; padding: 5px; border: 0px currentColor; border-image: none; width: auto; text-align: left; color: rgb(57, 51, 24); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; overflow: auto; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; display: block; -ms-word-wrap: normal; max-height: 600px; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(239, 240, 241); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;&lt;CODE style="margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; line-height: inherit; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-style: inherit; font-variant: inherit; font-weight: inherit; vertical-align: baseline; white-space: inherit; font-stretch: inherit; background-color: rgb(239, 240, 241);"&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;on&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; youth&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Rank1&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;=&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;distinct&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; TF&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Location&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;,&lt;/SPAN&gt; 
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;and&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;if&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; youth&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Rank1&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;≠&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; TF&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;location &lt;/SPAN&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;then&lt;/SPAN&gt; 
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;merge&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;on&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; youth&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Rank2&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; TF&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;location&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;,&lt;/SPAN&gt; 
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;if&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; youth&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Rank2&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;≠&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; TF&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;location &lt;/SPAN&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;then&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;merge&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; at 
youth&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Rank3 &lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; TF&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;location&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; etc&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;.&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;Put plainly: “Merge on rank1 unless rank1 location is no longer available, then merge on rank2, unless rank2 location is no longer available, and on down the line, etc., etc., until all option are exhausted and foster care (i.e., alternative services). Is the only option.&lt;BR /&gt;I’ve had no success getting this to work. I haven’t even been successful getting the union function to work. About the only successful thing I’ve done in SQL so far is create a view of a single dataset. It’s pretty sad. I’ve been following this guidance, but I get hung up around the “where” command:&lt;/P&gt;
&lt;PRE class="lang-sql prettyprint prettyprinted" style="margin: 0px 0px 1em; padding: 5px; border: 0px currentColor; border-image: none; width: auto; text-align: left; color: rgb(57, 51, 24); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; overflow: auto; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; display: block; -ms-word-wrap: normal; max-height: 600px; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(239, 240, 241); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;&lt;CODE style="margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; line-height: inherit; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-style: inherit; font-variant: inherit; font-weight: inherit; vertical-align: baseline; white-space: inherit; font-stretch: inherit; background-color: rgb(239, 240, 241);"&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;proc&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; sql&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;;&lt;/SPAN&gt; &lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;Calls the SQL &lt;/SPAN&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;procedure&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;*/;&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;create&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;table&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; x &lt;/SPAN&gt;&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;as&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Tells SAS to create a table called x*/&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;select&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Specifies the column(s) to be selected*/&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;from&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Specificies the tables(s) (data sets) to be queried*/&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;where&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Subjests the data based on a condition*/&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;group&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;by&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Classifies the data into groups based on the specified 
column(s)*/&lt;/SPAN&gt;
&lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;order&lt;/SPAN&gt; &lt;SPAN class="kwd" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(16, 16, 148); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;by&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Sorts the resulting rows observations) by the specified 
column(s)*/&lt;/SPAN&gt;
&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;;&lt;/SPAN&gt;&lt;SPAN class="pln" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt; quit&lt;/SPAN&gt;&lt;SPAN class="pun" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(48, 51, 54); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;;&lt;/SPAN&gt; &lt;SPAN class="com" style="font: inherit; margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; color: rgb(133, 140, 147); vertical-align: baseline; font-size-adjust: inherit; font-stretch: inherit;"&gt;/*Ends the proc sql procedure*/&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;Frankly, I’m stuck and I could use some advice. This greenhorn in me is in way over his head.&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;I appreciate any help or guidance anyone might lend.&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;Cheers!&lt;/P&gt;
&lt;P style="margin: 0px 0px 1em; padding: 0px; border: 0px currentColor; border-image: none; text-align: left; color: rgb(36, 39, 41); text-transform: none; line-height: inherit; text-indent: 0px; letter-spacing: normal; clear: both; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; vertical-align: baseline; white-space: normal; orphans: 2; widows: 2; font-stretch: inherit; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;P&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 19:06:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365792#M86929</guid>
      <dc:creator>PhilG</dc:creator>
      <dc:date>2017-06-09T19:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use proc sql  to dynamically merge two dataset in order to simulate placement decisions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365797#M86930</link>
      <description>&lt;P&gt;if you can give small amount of data of what you want and have then someone can easily help you&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 19:24:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365797#M86930</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-09T19:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use proc sql to dynamically merge two datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365800#M86928</link>
      <description>&lt;P&gt;it is really hard to envision any pratical approaches before you show some sample data, both HAVE and WANT.&lt;/P&gt;
&lt;P&gt;For example, when you say 'not available' (which is a key concept in your description),&amp;nbsp;which of the following&amp;nbsp;do you really mean in data language:&lt;/P&gt;
&lt;P&gt;1. The field&amp;nbsp;is missing.&lt;/P&gt;
&lt;P&gt;2. The field is not missing, but the value is not matching.&lt;/P&gt;
&lt;P&gt;3. Others?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is No1. SAS has a straightforward function coalesce() worth looking up. Could be as simple as:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql;
create table want as
select * from 
h1 
left join 
h2
on h1.location=coalesce(h2.rank1,h2.rank2, h3.rank3...down then line etc)
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is No2 or 3, then it&amp;nbsp;may involve some more complex coding. However, without seeing your data structure, this is all guessing.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 19:30:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365800#M86928</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2017-06-09T19:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use proc sql  to dynamically merge two dataset in order to simulate placement decisions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365803#M86931</link>
      <description>&lt;P&gt;Repeating the exact same message does not add any information needed to provide solutions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest also paying a little attention to text formatting. It is hard to tell what is imporant or where a "rule" starts (or ends).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Frankly we do not need to know what any variables represent in most cases but what the input data sets look like and what the desired output for that given example input should be is crucial.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And one should not start using SAS Macros if you do not have basic code to accomplish the task first.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 19:44:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365803#M86931</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-09T19:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use proc sql to dynamically merge two datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365805#M86933</link>
      <description>&lt;P&gt;&amp;nbsp;Really trying to do that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Youth dataset&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="528"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;Y_ID&lt;/TD&gt;
&lt;TD width="64"&gt;age&lt;/TD&gt;
&lt;TD width="64"&gt;sex&lt;/TD&gt;
&lt;TD width="64"&gt;rank1&lt;/TD&gt;
&lt;TD width="64"&gt;rank2&lt;/TD&gt;
&lt;TD width="64"&gt;rank3&lt;/TD&gt;
&lt;TD width="64"&gt;rank4&lt;/TD&gt;
&lt;TD width="80"&gt;alternative services&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;122&lt;/TD&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;m&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;15&lt;/TD&gt;
&lt;TD&gt;14&lt;/TD&gt;
&lt;TD&gt;m&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;5&lt;/TD&gt;
&lt;TD&gt;15&lt;/TD&gt;
&lt;TD&gt;m&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;666&lt;/TD&gt;
&lt;TD&gt;16&lt;/TD&gt;
&lt;TD&gt;f&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;561&lt;/TD&gt;
&lt;TD&gt;16&lt;/TD&gt;
&lt;TD&gt;m&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;TD&gt;21&lt;/TD&gt;
&lt;TD&gt;m&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;46&lt;/TD&gt;
&lt;TD&gt;14&lt;/TD&gt;
&lt;TD&gt;m&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;5555&lt;/TD&gt;
&lt;TD&gt;17&lt;/TD&gt;
&lt;TD&gt;m&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;8484&lt;/TD&gt;
&lt;TD&gt;13&lt;/TD&gt;
&lt;TD&gt;f&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;48&lt;/TD&gt;
&lt;TD&gt;5&lt;/TD&gt;
&lt;TD&gt;m&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Location Dataset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="128" style="width: 96pt; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL width="64" style="width: 48pt;" span="2" /&gt;&lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0.5pt 0px 0px 0.5pt; border-style: solid none none solid; border-color: windowtext black black windowtext; width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Bed_ID&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD width="64" style="border-width: 0.5pt 0.5pt 0px 0px; border-style: solid solid none none; border-color: windowtext windowtext black black; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Location&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" style="border-width: 0.5pt 0px 0.5pt 0.5pt; border-style: solid none solid solid; border-color: windowtext black windowtext windowtext; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;A&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" style="border-width: 0px 0px 0px 0.5pt; border-style: none none none solid; border-color: black black black windowtext; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0px 0px; border-style: none solid none none; border-color: black windowtext black black; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;B&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" style="border-width: 0.5pt 0px 0.5pt 0.5pt; border-style: solid none solid solid; border-color: windowtext black windowtext windowtext; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;3&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;C&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" style="border-width: 0px 0px 0px 0.5pt; border-style: none none none solid; border-color: black black black windowtext; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0px 0px; border-style: none solid none none; border-color: black windowtext black black; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;D&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" style="border-width: 0.5pt 0px 0.5pt 0.5pt; border-style: solid none solid solid; border-color: windowtext black windowtext windowtext; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;5&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;D&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" style="border-width: 0px 0px 0px 0.5pt; border-style: none none none solid; border-color: black black black windowtext; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;6&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0px 0px; border-style: none solid none none; border-color: black windowtext black black; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;D&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" style="border-width: 0.5pt 0px 0.5pt 0.5pt; border-style: solid none solid solid; border-color: windowtext black windowtext windowtext; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;7&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;A&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" style="border-width: 0px 0px 0px 0.5pt; border-style: none none none solid; border-color: black black black windowtext; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;8&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0px 0px; border-style: none solid none none; border-color: black windowtext black black; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;C&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" style="border-width: 0.5pt 0px 0.5pt 0.5pt; border-style: solid none solid solid; border-color: windowtext black windowtext windowtext; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;9&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;B&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" style="border-width: 0px 0px 0.5pt 0.5pt; border-style: none none solid solid; border-color: black black windowtext windowtext; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;10&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;D&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proposed merge would look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="656"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;Y_ID&lt;/TD&gt;
&lt;TD width="64"&gt;age&lt;/TD&gt;
&lt;TD width="64"&gt;sex&lt;/TD&gt;
&lt;TD width="64"&gt;rank1&lt;/TD&gt;
&lt;TD width="64"&gt;rank2&lt;/TD&gt;
&lt;TD width="64"&gt;rank3&lt;/TD&gt;
&lt;TD width="64"&gt;rank4&lt;/TD&gt;
&lt;TD width="80"&gt;alternative services&lt;/TD&gt;
&lt;TD width="64"&gt;location&lt;/TD&gt;
&lt;TD width="64"&gt;Bed_ID&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;122&lt;/TD&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;m&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;15&lt;/TD&gt;
&lt;TD&gt;14&lt;/TD&gt;
&lt;TD&gt;m&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;5&lt;/TD&gt;
&lt;TD&gt;15&lt;/TD&gt;
&lt;TD&gt;m&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;666&lt;/TD&gt;
&lt;TD&gt;16&lt;/TD&gt;
&lt;TD&gt;f&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;561&lt;/TD&gt;
&lt;TD&gt;16&lt;/TD&gt;
&lt;TD&gt;m&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;TD&gt;21&lt;/TD&gt;
&lt;TD&gt;m&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;46&lt;/TD&gt;
&lt;TD&gt;14&lt;/TD&gt;
&lt;TD&gt;m&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;5555&lt;/TD&gt;
&lt;TD&gt;17&lt;/TD&gt;
&lt;TD&gt;m&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;7&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;8484&lt;/TD&gt;
&lt;TD&gt;13&lt;/TD&gt;
&lt;TD&gt;f&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;48&lt;/TD&gt;
&lt;TD&gt;5&lt;/TD&gt;
&lt;TD&gt;m&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Fri, 09 Jun 2017 19:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365805#M86933</guid>
      <dc:creator>PhilG</dc:creator>
      <dc:date>2017-06-09T19:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use proc sql  to dynamically merge two dataset in order to simulate placement decisions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365810#M86934</link>
      <description>&lt;P&gt;Didn't mean to do that :).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Again, it is the sql commands that I'm trying to learn. I've been quite successful using&amp;nbsp;other "procs"&amp;nbsp;in macros.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 19:57:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365810#M86934</guid>
      <dc:creator>PhilG</dc:creator>
      <dc:date>2017-06-09T19:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use proc sql to dynamically merge two datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365813#M86935</link>
      <description>&lt;P&gt;So what is the rule that assigns a location and Bed_id pair to a specific Y_ID value?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 20:04:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365813#M86935</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-09T20:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use proc sql to dynamically merge two datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365819#M86936</link>
      <description>&lt;P&gt;Rank1 then rank2 then rank3. etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want the location&amp;nbsp; name&amp;nbsp;in rank1 to pair with a location&amp;nbsp; name in the location column. If the location name&amp;nbsp;in rank1 cannot be found in the location column (because it has been previously assigned), then I want it to pair based on rank2 and on down the line. Again, I don't even know if this is possible....&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 20:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365819#M86936</guid>
      <dc:creator>PhilG</dc:creator>
      <dc:date>2017-06-09T20:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use proc sql to dynamically merge two datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365824#M86937</link>
      <description>&lt;P&gt;This is a not bullet-proof approach, I need to leave office now so I may get back to you if this code needs patch. Anyway, hope this can get you started;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data youth;
	infile cards truncover;
	input (Y_ID age sex rank1 rank2 rank3 rank4) (:$8.);
	cards;
122 12 m B C       
15 14 m B C       
5 15 m B D C     
666 16 f C D       
561 16 m D B C     
8 21 m A D C B   
46 14 m D C B     
5555 17 m A B D C   
8484 13 f D C       
48 5 m C         
;

data location;
	input Bed_ID $ Location $;
	cards;
1 A 
2 B 
3 C 
4 D 
5 D 
6 D 
7 A 
8 C 
9 B 
10 D 
;

data want;
	if _n_=1 then
		do;
			if 0 then
				set location;
			declare hash h(dataset:'location', multidata:'y' );
			h.definekey('location');
	h.definedata(all:
			'y');
			h.definedone();
		end;

	set youth;
	array rank rank:;
	do over rank;
		if h.find(key:rank) = 0 then
			do;
				output;
				rc=h.removedup(key:rank);
				leave;
			end;
	end;

	drop rc;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;btw, I doubt SQL will&amp;nbsp;support the&amp;nbsp;feature you are looking for, even it could, it can be very complex. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 20:25:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365824#M86937</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2017-06-09T20:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use proc sql to dynamically merge two datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365827#M86938</link>
      <description>&lt;P&gt;Fair enough! Thank you very for your assistance! I give this a shot and see if I can't disect what you've done here. Cheers! P&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 20:45:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365827#M86938</guid>
      <dc:creator>PhilG</dc:creator>
      <dc:date>2017-06-09T20:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use proc sql to dynamically merge two datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365831#M86939</link>
      <description>&lt;P&gt;In general SQL is not a good choice when order of operation is required. SQL is built around set operations (intersect union and such) not if first or second is not available use n'th choice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Examining multiple rows and columns at the same time is more of a SAS/IML program&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your example output data has different ranks that input:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="528"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;8484&lt;/TD&gt;
&lt;TD&gt;13&lt;/TD&gt;
&lt;TD&gt;f&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;vs&lt;/P&gt;
&lt;TABLE width="656"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;8484&lt;/TD&gt;
&lt;TD&gt;13&lt;/TD&gt;
&lt;TD&gt;f&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 20:54:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365831#M86939</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-09T20:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use proc sql to dynamically merge two datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365834#M86940</link>
      <description>Oops. This is not the actual data I'm using. Just for illustrative purposes. I can't post my actual data. It is sensitive.</description>
      <pubDate>Fri, 09 Jun 2017 20:59:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365834#M86940</guid>
      <dc:creator>PhilG</dc:creator>
      <dc:date>2017-06-09T20:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use proc sql to dynamically merge two datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365836#M86941</link>
      <description>&lt;P&gt;I appreciate your expertise! Thank you. I'll give both of these a shot and see if I can't figure it out. Would it be possible to "pick your brain a little" offline, so to speak? About the solutions y'all provideed? Email of course? Cheers! P&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 21:01:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/365836#M86941</guid>
      <dc:creator>PhilG</dc:creator>
      <dc:date>2017-06-09T21:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use proc sql to dynamically merge two datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/366321#M87131</link>
      <description>&lt;P&gt;I'm not sure why, but the actual syntax solution that was in the email I recieved does not appear in the message-board thingy. Any road, the solution that you provided worked brilliantly! I was able to modify it such that it worked on a different dataset. So, again, thank you! Well done! This is brilliant! I can't thank you enough. If you can get to Oregon, you are invited to the whole hog BBQ I'm hosting in the backyard on the 24th! It would be a pleasure.&amp;nbsp; Cheers! P&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS&amp;gt; I'm sure I'm going to run into further question,&amp;nbsp; so thank you in advance for your patience.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 19:52:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/366321#M87131</guid>
      <dc:creator>PhilG</dc:creator>
      <dc:date>2017-06-12T19:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use proc sql to dynamically merge two datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/366322#M87132</link>
      <description>Would it be too bother some to highlight specific areas of the syntax, so I gain a deeper understanding of the process you've created here?</description>
      <pubDate>Mon, 12 Jun 2017 19:55:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-proc-sql-to-dynamically-merge-two-datasets/m-p/366322#M87132</guid>
      <dc:creator>PhilG</dc:creator>
      <dc:date>2017-06-12T19:55:10Z</dc:date>
    </item>
  </channel>
</rss>

