<?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 Merging with Many to Few in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Merging-with-Many-to-Few/m-p/345827#M63532</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to merge two data sets together to use in creating a calculated field. Here's the code for the sorting and merging:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=all_batting out=sorted_all;
	by descending year_id;
	run;
proc sort data=bat_weights out=sorted_bat_weights;
	where season between 1981 and 2015;
	by descending season;
	run;
data all_with_weights;
	merge sorted_all sorted_bat_weights (rename=(season=year_id));
	by year_id;
	run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here's the error:&amp;nbsp;ERROR: BY variables are not properly sorted on data set WORK.SORTED_BAT_WEIGHTS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are pictures of what each sorted data set looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8048i16A6886CAFB2BC6B/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="sorted_1.JPG" title="sorted_1.JPG" align="right" /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8049iEDC2B2C3F86F4C0C/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="sorted_2.JPG" title="sorted_2.JPG" align="right" /&gt;The sorted_all table contains multiple records for each year, where as the bat_weights only has one row per year. I'm not too sure what's going wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Justin&lt;/P&gt;</description>
    <pubDate>Thu, 30 Mar 2017 16:56:37 GMT</pubDate>
    <dc:creator>jl1005</dc:creator>
    <dc:date>2017-03-30T16:56:37Z</dc:date>
    <item>
      <title>Merging with Many to Few</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-with-Many-to-Few/m-p/345827#M63532</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to merge two data sets together to use in creating a calculated field. Here's the code for the sorting and merging:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=all_batting out=sorted_all;
	by descending year_id;
	run;
proc sort data=bat_weights out=sorted_bat_weights;
	where season between 1981 and 2015;
	by descending season;
	run;
data all_with_weights;
	merge sorted_all sorted_bat_weights (rename=(season=year_id));
	by year_id;
	run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here's the error:&amp;nbsp;ERROR: BY variables are not properly sorted on data set WORK.SORTED_BAT_WEIGHTS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are pictures of what each sorted data set looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8048i16A6886CAFB2BC6B/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="sorted_1.JPG" title="sorted_1.JPG" align="right" /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8049iEDC2B2C3F86F4C0C/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="sorted_2.JPG" title="sorted_2.JPG" align="right" /&gt;The sorted_all table contains multiple records for each year, where as the bat_weights only has one row per year. I'm not too sure what's going wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Justin&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 16:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-with-Many-to-Few/m-p/345827#M63532</guid>
      <dc:creator>jl1005</dc:creator>
      <dc:date>2017-03-30T16:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: Merging with Many to Few</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-with-Many-to-Few/m-p/345828#M63533</link>
      <description>&lt;P&gt;You are not sorting by the same desired by variable for both sets in your merge.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 16:58:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-with-Many-to-Few/m-p/345828#M63533</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-03-30T16:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: Merging with Many to Few</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-with-Many-to-Few/m-p/345838#M63534</link>
      <description>Isn't that what the rename is doing in the data step? It's renaming season to year_id so that they are the same variable names.&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Mar 2017 17:13:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-with-Many-to-Few/m-p/345838#M63534</guid>
      <dc:creator>jl1005</dc:creator>
      <dc:date>2017-03-30T17:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Merging with Many to Few</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-with-Many-to-Few/m-p/345839#M63535</link>
      <description>&lt;P&gt;Oh. I did not look closely enough. What does your log say? Is there an error or are you just not seeing what you expect.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 17:15:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-with-Many-to-Few/m-p/345839#M63535</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-03-30T17:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Merging with Many to Few</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-with-Many-to-Few/m-p/345842#M63536</link>
      <description>&lt;P&gt;Other than the "by variables" error, that is. I'm wondering if something else is happening upstream.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 17:19:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-with-Many-to-Few/m-p/345842#M63536</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-03-30T17:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Merging with Many to Few</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-with-Many-to-Few/m-p/345844#M63537</link>
      <description>&lt;P&gt;Here's the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 The SAS System 22:47 Wednesday, March 29, 2017&lt;/P&gt;&lt;P&gt;1 ;*';*";*/;quit;run;&lt;BR /&gt;2 OPTIONS PAGENO=MIN;&lt;BR /&gt;3 %LET _CLIENTTASKLABEL='Program (2)';&lt;BR /&gt;4 %LET _CLIENTPROCESSFLOWNAME='Process Flow (3)';&lt;BR /&gt;5 %LET _CLIENTPROJECTPATH='C:\Users\jblon\Documents\My SAS Files\baseball_2.egp';&lt;BR /&gt;6 %LET _CLIENTPROJECTNAME='baseball_2.egp';&lt;BR /&gt;7 %LET _SASPROGRAMFILE=;&lt;BR /&gt;8&lt;BR /&gt;9 ODS _ALL_ CLOSE;&lt;BR /&gt;10 OPTIONS DEV=ACTIVEX;&lt;BR /&gt;11 GOPTIONS XPIXELS=0 YPIXELS=0;&lt;BR /&gt;12 FILENAME EGSR TEMP;&lt;BR /&gt;13 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR&lt;BR /&gt;14 STYLE=HtmlBlue&lt;BR /&gt;15 STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")&lt;BR /&gt;16 NOGTITLE&lt;BR /&gt;17 NOGFOOTNOTE&lt;BR /&gt;18 GPATH=&amp;amp;sasworklocation&lt;BR /&gt;19 ENCODING=UTF8&lt;BR /&gt;20 options(rolap="on")&lt;BR /&gt;21 ;&lt;BR /&gt;NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR&lt;BR /&gt;22&lt;BR /&gt;23 GOPTIONS ACCESSIBLE;&lt;BR /&gt;24 data all_with_weights;&lt;BR /&gt;25 merge sorted_all sorted_bat_weights (rename=(season=year_id));&lt;BR /&gt;26 by year_id;&lt;BR /&gt;27 run;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" color="#FF0000"&gt;ERROR: BY variables are not properly sorted on data set WORK.SORTED_BAT_WEIGHTS.&lt;/FONT&gt;&lt;BR /&gt;year_id=2015 bat_id=aardd001 G=53 AB=0 R=0 H=0 2B=0 3B=0 HR=. RBI=0 SB=0 CS=0 BB=0 SO=0 IBB=0 HBP=0 SH=0 SF=0 _NAME_=count&lt;BR /&gt;generic_out=. strikeout=1 stolen_base=. pickoff=. wild_pitch=. walk=. intentional_walk=. interference=. error=. fielders_choice=.&lt;BR /&gt;single=. double=. caught_stealing=. balk=. hit_by_pitch=. passed_ball=. foul_error=. triple=. other_advance=. defensive_indiff=.&lt;BR /&gt;wOBA=0.313 wOBAScale=1.251 wBB=0.687 wHBP=0.718 w1B=0.881 w2B=1.256 w3B=1.594 wHR=2.065 runSB=0.2 runCS=-0.392 R/PA=0.113 R/W=9.421&lt;BR /&gt;cFIP=3.134 FIRST.year_id=1 LAST.year_id=1 _ERROR_=1 _N_=1&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: There were 2 observations read from the data set WORK.SORTED_ALL.&lt;BR /&gt;NOTE: There were 2 observations read from the data set WORK.SORTED_BAT_WEIGHTS.&lt;BR /&gt;WARNING: The data set WORK.ALL_WITH_WEIGHTS may be incomplete. When this step was stopped there were 0 observations and 52&lt;BR /&gt;variables.&lt;BR /&gt;WARNING: Data set WORK.ALL_WITH_WEIGHTS was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.10 seconds&lt;BR /&gt;cpu time 0.03 seconds&lt;/P&gt;&lt;P&gt;28&lt;BR /&gt;29 GOPTIONS NOACCESSIBLE;&lt;BR /&gt;30 %LET _CLIENTTASKLABEL=;&lt;BR /&gt;31 %LET _CLIENTPROCESSFLOWNAME=;&lt;BR /&gt;32 %LET _CLIENTPROJECTPATH=;&lt;BR /&gt;33 %LET _CLIENTPROJECTNAME=;&lt;BR /&gt;34 %LET _SASPROGRAMFILE=;&lt;BR /&gt;35&lt;BR /&gt;36 ;*';*";*/;quit;run;&lt;BR /&gt;37 ODS _ALL_ CLOSE;&lt;BR /&gt;38&lt;BR /&gt;39&lt;BR /&gt;2 The SAS System 22:47 Wednesday, March 29, 2017&lt;/P&gt;&lt;P&gt;40 QUIT; RUN;&lt;BR /&gt;41&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 17:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-with-Many-to-Few/m-p/345844#M63537</guid>
      <dc:creator>jl1005</dc:creator>
      <dc:date>2017-03-30T17:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Merging with Many to Few</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-with-Many-to-Few/m-p/345847#M63538</link>
      <description>&lt;P&gt;You sort descending, but then&amp;nbsp; merge by year_id NOT descending.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 17:25:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-with-Many-to-Few/m-p/345847#M63538</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-03-30T17:25:12Z</dc:date>
    </item>
  </channel>
</rss>

