<?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 How to combine two tables by using MIN and MAX numbers? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-tables-by-using-MIN-and-MAX-numbers/m-p/925601#M364241</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I would like to combine two datasets, HAVE and Weekcode.&amp;nbsp; I would like to use MIN and MAX numbers in the weekcode column to set the "WANT" dataset range. Please help.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;  
	Format Weekcode 4.0 Test 3.0 Pos 3.0 Lab 4.0; 
	infile datalines delimiter='/'; 
	input Weekcode Test Pos Lab;  
	datalines;                     
2102/ 8/ 3/ 256/
2103/ 3/ 1/ 619/
2106/ 5/ 2/ 2066/
2107/ 3/ 0/ 256/
2110/ 7/ 6/ 619/
;  

data weekcode;  
	Format Weekcode 4.0; 
	infile datalines delimiter='/'; 
	input Weekcode;  
	datalines;                     
2009/
2100/
2101/ 
2102/
2103/ 
2104/
2105/ 
2106/ 
2107/ 
2108/ 
2109/ 
2110/ 
2111/ 
2112/ 
2113/ 
2114/ 
2115/ 
;  

data WANT;  
	Format Weekcode 4.0 Test 3.0 Pos 3.0 Lab 4.0; 
	infile datalines delimiter='/'; 
	input Weekcode Test Pos Lab;  
	datalines;                     
2102/ 8/ 3/ 256/
2103/ 3/ 1/ 619/
2104/ 0/ 0/ 0/
2105/ 0/ 0/ 0/
2106/ 5/ 2/ 2066/
2107/ 3/ 0/ 256/
2108/ 0/ 0/ 0/
2109/ 0/ 0/ 0/
2110/ 7/ 6/ 619/
;  
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Apr 2024 16:34:08 GMT</pubDate>
    <dc:creator>ybz12003</dc:creator>
    <dc:date>2024-04-24T16:34:08Z</dc:date>
    <item>
      <title>How to combine two tables by using MIN and MAX numbers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-tables-by-using-MIN-and-MAX-numbers/m-p/925601#M364241</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I would like to combine two datasets, HAVE and Weekcode.&amp;nbsp; I would like to use MIN and MAX numbers in the weekcode column to set the "WANT" dataset range. Please help.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;  
	Format Weekcode 4.0 Test 3.0 Pos 3.0 Lab 4.0; 
	infile datalines delimiter='/'; 
	input Weekcode Test Pos Lab;  
	datalines;                     
2102/ 8/ 3/ 256/
2103/ 3/ 1/ 619/
2106/ 5/ 2/ 2066/
2107/ 3/ 0/ 256/
2110/ 7/ 6/ 619/
;  

data weekcode;  
	Format Weekcode 4.0; 
	infile datalines delimiter='/'; 
	input Weekcode;  
	datalines;                     
2009/
2100/
2101/ 
2102/
2103/ 
2104/
2105/ 
2106/ 
2107/ 
2108/ 
2109/ 
2110/ 
2111/ 
2112/ 
2113/ 
2114/ 
2115/ 
;  

data WANT;  
	Format Weekcode 4.0 Test 3.0 Pos 3.0 Lab 4.0; 
	infile datalines delimiter='/'; 
	input Weekcode Test Pos Lab;  
	datalines;                     
2102/ 8/ 3/ 256/
2103/ 3/ 1/ 619/
2104/ 0/ 0/ 0/
2105/ 0/ 0/ 0/
2106/ 5/ 2/ 2066/
2107/ 3/ 0/ 256/
2108/ 0/ 0/ 0/
2109/ 0/ 0/ 0/
2110/ 7/ 6/ 619/
;  
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 16:34:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-tables-by-using-MIN-and-MAX-numbers/m-p/925601#M364241</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2024-04-24T16:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two tables by using MIN and MAX numbers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-tables-by-using-MIN-and-MAX-numbers/m-p/925604#M364242</link>
      <description>&lt;P&gt;Since Weekcode appears in both your Have and Weekcode data sets which dataset is to be used to generate the Min and Max you are thinking of?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I might &lt;STRONG&gt;guess&lt;/STRONG&gt; :&lt;/P&gt;
&lt;PRE&gt;proc sql noprint;
   select min(weekcode), max(weekcode) into :minweek, :maxweek
   from have
   ;
quit;

data want; 
  merge have weekcode (where=(&amp;amp;minweek. le weekcode le &amp;amp;maxweek.));
  by weekcode;
run;&lt;/PRE&gt;
&lt;P&gt;(Trivial to add the 0 instead of missing if actually desired. I'm cautious about doing such though.)&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 16:55:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-tables-by-using-MIN-and-MAX-numbers/m-p/925604#M364242</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-24T16:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two tables by using MIN and MAX numbers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-tables-by-using-MIN-and-MAX-numbers/m-p/925607#M364243</link>
      <description>That works!&lt;BR /&gt;</description>
      <pubDate>Wed, 24 Apr 2024 17:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-tables-by-using-MIN-and-MAX-numbers/m-p/925607#M364243</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2024-04-24T17:10:58Z</dc:date>
    </item>
  </channel>
</rss>

