<?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 help understanding syntax with proc sql in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/help-understanding-syntax-with-proc-sql/m-p/587344#M14675</link>
    <description>&lt;P&gt;hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am having trouble understanding the syntax in this proc sql step.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My questions are&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) I am not sure how to figure out where the a vs. b vs. c datasets are coming from. A lot of the variables listed under the select step are not in the OLDTABLE dataset, so i dont know where to look for them.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) this step keeps ending early in the log due to an error and i am not sure why:&amp;nbsp;&lt;CODE class=" language-sas"&gt;a.RECIP_ID=b.RECIP_ID&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;thank you!&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
	create table NEWTABLE as
	select b.var1 
	     , 2016 as year  
	     , c.var2 
	     , c.var3 
             , c.var4  
	     , c.var5 
	     , '-' as  var6 
	     , c.var7 &lt;BR /&gt;             , a.var8 
	     , a.var9 
	     , a.var10  
	from 
		(select distinct orid
	           , Name as facility
	           , cnty as county
	           , ercategory           
	           , count(*) as visits
	      from OLDTABLE
	      group by 1, 2, 3, 4
	     ) as a 
		 left join
		 (select distinct orid, 
			case  
			when count(*) eq 1 then '1 Visit' 
			when count(*) eq 2 then '2 Visits' 
			when count(*) &amp;gt;2 and count(*)&amp;lt;6  then '3 to 5 Visits' 
			when count(*) &amp;gt;5 and count(*)&amp;lt;11  then '6 to 10 Visits' 
			when count(*) &amp;gt;10 and count(*)&amp;lt;26  then '11 to 25 Visits' 
			when count(*) &amp;gt;25  then '26 + Visits' 
			else
			'No Visits'
			end as ed_freq_cat
			from OLDTABLE
			group by 1
		  ) as b  on a.RECIP_ID=b.RECIP_ID
	      left join 
		  (select * from sdelig.Member_month_rolloff
	where MBR_MTH_YR_MTH between '201607' and '201706') as c
		  on a.RECIP_ID=c.RECIP_ID;
 quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Sep 2019 19:34:55 GMT</pubDate>
    <dc:creator>marleeakerson</dc:creator>
    <dc:date>2019-09-09T19:34:55Z</dc:date>
    <item>
      <title>help understanding syntax with proc sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/help-understanding-syntax-with-proc-sql/m-p/587344#M14675</link>
      <description>&lt;P&gt;hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am having trouble understanding the syntax in this proc sql step.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My questions are&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) I am not sure how to figure out where the a vs. b vs. c datasets are coming from. A lot of the variables listed under the select step are not in the OLDTABLE dataset, so i dont know where to look for them.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) this step keeps ending early in the log due to an error and i am not sure why:&amp;nbsp;&lt;CODE class=" language-sas"&gt;a.RECIP_ID=b.RECIP_ID&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;thank you!&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
	create table NEWTABLE as
	select b.var1 
	     , 2016 as year  
	     , c.var2 
	     , c.var3 
             , c.var4  
	     , c.var5 
	     , '-' as  var6 
	     , c.var7 &lt;BR /&gt;             , a.var8 
	     , a.var9 
	     , a.var10  
	from 
		(select distinct orid
	           , Name as facility
	           , cnty as county
	           , ercategory           
	           , count(*) as visits
	      from OLDTABLE
	      group by 1, 2, 3, 4
	     ) as a 
		 left join
		 (select distinct orid, 
			case  
			when count(*) eq 1 then '1 Visit' 
			when count(*) eq 2 then '2 Visits' 
			when count(*) &amp;gt;2 and count(*)&amp;lt;6  then '3 to 5 Visits' 
			when count(*) &amp;gt;5 and count(*)&amp;lt;11  then '6 to 10 Visits' 
			when count(*) &amp;gt;10 and count(*)&amp;lt;26  then '11 to 25 Visits' 
			when count(*) &amp;gt;25  then '26 + Visits' 
			else
			'No Visits'
			end as ed_freq_cat
			from OLDTABLE
			group by 1
		  ) as b  on a.RECIP_ID=b.RECIP_ID
	      left join 
		  (select * from sdelig.Member_month_rolloff
	where MBR_MTH_YR_MTH between '201607' and '201706') as c
		  on a.RECIP_ID=c.RECIP_ID;
 quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2019 19:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/help-understanding-syntax-with-proc-sql/m-p/587344#M14675</guid>
      <dc:creator>marleeakerson</dc:creator>
      <dc:date>2019-09-09T19:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: help understanding syntax with proc sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/help-understanding-syntax-with-proc-sql/m-p/587353#M14676</link>
      <description>&lt;P&gt;Post the log please.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2019 20:18:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/help-understanding-syntax-with-proc-sql/m-p/587353#M14676</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-09-09T20:18:43Z</dc:date>
    </item>
  </channel>
</rss>

