<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Proc Means to SQL code in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Means-to-SQL-code/m-p/213931#M52748</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Proc Means is one of the procedures that are enhanced for in-database processing so may be translating the logic into SQL won't give you anything else than more work and higher complexity code.&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/67327/HTML/default/viewer.htm#p0rbwzwi5gyyxwn1irfgkjgprt1p.htm" title="http://support.sas.com/documentation/cdl/en/proc/67327/HTML/default/viewer.htm#p0rbwzwi5gyyxwn1irfgkjgprt1p.htm"&gt;http://support.sas.com/documentation/cdl/en/proc/67327/HTML/default/viewer.htm#p0rbwzwi5gyyxwn1irfgkjgprt1p.htm&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haven't tried it but it's worth a shot: You could define below options before running your Proc Means code. Proc Means being an in-database enhanced procedures SAS will try to convert the proc syntax into SQL code and send it to the database. The options below will show you the SQL code generated in the SAS log. This will show you if SAS could translate the Proc Means code fully into SQL and if you still want to go for a SQL replacement then the code generated would also be a very good starting point for you (just copy/paste it).&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #545454; font-family: arial, sans-serif; font-size: small; background-color: #ffffff;"&gt;OPTIONS SASTRACE=',,,d' SASTRACELOC=SASLOG &lt;/SPAN&gt;&lt;SPAN style="font-weight: bold; color: #6a6a6a; font-family: arial, sans-serif; font-size: small; background-color: #ffffff;"&gt;NOSTSUFFIX&lt;/SPAN&gt;&lt;SPAN style="color: #545454; font-family: arial, sans-serif; font-size: small; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 May 2015 21:39:33 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2015-05-13T21:39:33Z</dc:date>
    <item>
      <title>Proc Means to SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Means-to-SQL-code/m-p/213925#M52742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sql&lt;BR /&gt;I am trying to convert the following code to SQL.&lt;/P&gt;&lt;P&gt;Any help on this would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc means data = temp missing no print chartype;&lt;/P&gt;&lt;P&gt;by source Year;&lt;/P&gt;&lt;P&gt;class cltname incentive; &lt;/P&gt;&lt;P&gt;va Elig overall initial consecutive;&lt;/P&gt;&lt;P&gt;output out = smry sum=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 09:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Means-to-SQL-code/m-p/213925#M52742</guid>
      <dc:creator>Aanch16167</dc:creator>
      <dc:date>2015-05-13T09:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Means to SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Means-to-SQL-code/m-p/213926#M52743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you can provide a small sample of the data so anyone trying to help can see the input/output that would be helpful.&amp;nbsp; Or use a sashelp. dataset for someone to manipulate in the same way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 14:32:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Means-to-SQL-code/m-p/213926#M52743</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-05-13T14:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Means to SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Means-to-SQL-code/m-p/213927#M52744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want the _type_ variable and associated behavior I would ask why? In SQL you will likely have to create 4 separate summary sets and then combine them. And if you add more class variables the number of sets goes up.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 15:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Means-to-SQL-code/m-p/213927#M52744</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-05-13T15:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Means to SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Means-to-SQL-code/m-p/213928#M52745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Aanch16167,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following example shows how to convert a PROC MEANS to PROC SQL. You can use it as starting point to create your own solution:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data grade;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input Name $ 1-8 Gender $ 11 Status $13 Year $ 15-16&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Section $ 18 Score 20-21 FinalGrade 23-24;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;Abbott&amp;nbsp;&amp;nbsp;&amp;nbsp; F 2 97 A 90 87&lt;/P&gt;&lt;P&gt;Branford&amp;nbsp; M 1 98 A 92 97&lt;/P&gt;&lt;P&gt;Crandell&amp;nbsp; M 2 98 B 81 71&lt;/P&gt;&lt;P&gt;Dennison&amp;nbsp; M 1 97 A 85 72&lt;/P&gt;&lt;P&gt;Edgar&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F 1 98 B 89 80&lt;/P&gt;&lt;P&gt;Faust&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; M 1 97 B 78 73&lt;/P&gt;&lt;P&gt;Greeley&amp;nbsp;&amp;nbsp; F 2 97 A 82 91&lt;/P&gt;&lt;P&gt;Hart&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F 1 98 B 84 80&lt;/P&gt;&lt;P&gt;Isley&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; M 2 97 A 88 86&lt;/P&gt;&lt;P&gt;Jasper&amp;nbsp;&amp;nbsp;&amp;nbsp; M 1 97 B 91 93&lt;/P&gt;&lt;P&gt;Charly&amp;nbsp;&amp;nbsp;&amp;nbsp; M 1&amp;nbsp;&amp;nbsp;&amp;nbsp; B 90 90&lt;/P&gt;&lt;P&gt;Sandra&amp;nbsp;&amp;nbsp;&amp;nbsp; F 2 98&amp;nbsp;&amp;nbsp; 95 88&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=Grade out=GradeBySection;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by section;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/****** PROC MEANS *******/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc means&lt;/STRONG&gt; data=GradeBySection missing noprint chartype;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by Section;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var Score FinalGrade;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; class Status Year;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; output out=Want_Means sum=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=Want_Means;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by Section Status Year _TYPE_;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/******* PROC SQL&amp;nbsp; *******/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt; noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create view type11 as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct Section, Status, Year, '11' as _TYPE_,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(*) as _FREQ_, sum(Score) as Score, sum(FinalGrade) as FinalGrade&lt;/P&gt;&lt;P&gt;&amp;nbsp; from grade&lt;/P&gt;&lt;P&gt;&amp;nbsp; group by Section, Status, Year;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create view type10 as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct Section, Status, '&amp;nbsp; ' as Year, '10' as _TYPE_,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(*) as _FREQ_, sum(Score) as Score, sum(FinalGrade) as FinalGrade&lt;/P&gt;&lt;P&gt;&amp;nbsp; from grade&lt;/P&gt;&lt;P&gt;&amp;nbsp; group by Section, Status&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create view type01 as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct Section, ' ' as Status, Year, '01' as _TYPE_,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(*) as _FREQ_, sum(Score) as Score, sum(FinalGrade) as FinalGrade&lt;/P&gt;&lt;P&gt;&amp;nbsp; from grade&lt;/P&gt;&lt;P&gt;&amp;nbsp; group by Section, year&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create view type00 as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct Section, ' ' as Status, '&amp;nbsp; ' as Year, '00' as _TYPE_,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(*) as _FREQ_, sum(Score) as Score, sum(FinalGrade) as FinalGrade&lt;/P&gt;&lt;P&gt;&amp;nbsp; from grade&lt;/P&gt;&lt;P&gt;&amp;nbsp; group by Section&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table Want_SQL as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from type11&lt;/P&gt;&lt;P&gt;&amp;nbsp; union all&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from type10&lt;/P&gt;&lt;P&gt;&amp;nbsp; union all&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from type01&lt;/P&gt;&lt;P&gt;&amp;nbsp; union all&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from type00&lt;/P&gt;&lt;P&gt;&amp;nbsp; order by 1,2,3,4;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/****** Compare the results *******************/&lt;/P&gt;&lt;P&gt;proc compare data=Want_Means compare=Want_SQL;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CTorres&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 20:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Means-to-SQL-code/m-p/213928#M52745</guid>
      <dc:creator>CTorres</dc:creator>
      <dc:date>2015-05-13T20:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Means to SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Means-to-SQL-code/m-p/213929#M52746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So, the following would be the solution (untested) for your proc means assuming the class variables are character type:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create view type11 as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct source, Year,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* from by statement in Proc means */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cltname, incentive,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* from class statement in Proc means */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '11' as _TYPE_, count(*) as _FREQ_,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* _TYPE_ and _FREQ_ variables&amp;nbsp; */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sum(Elig) as ELIG, sum(overall) as overal,&amp;nbsp;&amp;nbsp; /* SUM statistics for var statement */&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sum(initial) as initial, sum(consecutive) as conservative&lt;/P&gt;&lt;P&gt;&amp;nbsp; from temp&lt;/P&gt;&lt;P&gt;&amp;nbsp; group by&amp;nbsp; source, Year, cltname, incentive;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* from both by and class statements&amp;nbsp; */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create view type10 as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct source, Year,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cltname, ' ' as incentive,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '10' as _TYPE_, count(*) as _FREQ_,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sum(Elig) as ELIG, um(overall) as overal, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sum(initial) as initial, sum(consecutive) as conservative&lt;/P&gt;&lt;P&gt;&amp;nbsp; from temp&lt;/P&gt;&lt;P&gt;&amp;nbsp; group by&amp;nbsp; source, Year, cltname;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create view type01 as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct source, Year,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' ' as cltname, incentive,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '01' as _TYPE_, count(*) as _FREQ_,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sum(Elig) as ELIG, um(overall) as overal, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sum(initial) as initial, sum(consecutive) as conservative&lt;/P&gt;&lt;P&gt;&amp;nbsp; from temp&lt;/P&gt;&lt;P&gt;&amp;nbsp; group by&amp;nbsp; source, Year, incentive;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create view type00 as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct source, Year,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' ' as cltname, ' ' as incentive,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '00' as _TYPE_, count(*) as _FREQ_,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sum(Elig) as ELIG, um(overall) as overal, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sum(initial) as initial, sum(consecutive) as conservative&lt;/P&gt;&lt;P&gt;&amp;nbsp; from temp&lt;/P&gt;&lt;P&gt;&amp;nbsp; group by&amp;nbsp; source, Year;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table smry as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from type11&lt;/P&gt;&lt;P&gt;&amp;nbsp; union all&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from type10&lt;/P&gt;&lt;P&gt;&amp;nbsp; union all&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from type01&lt;/P&gt;&lt;P&gt;&amp;nbsp; union all&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from type00&lt;/P&gt;&lt;P&gt;&amp;nbsp; order by 1,2,3,4;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CTorres&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 20:59:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Means-to-SQL-code/m-p/213929#M52746</guid>
      <dc:creator>CTorres</dc:creator>
      <dc:date>2015-05-13T20:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Means to SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Means-to-SQL-code/m-p/213930#M52747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In my humble opinion using SQL instead of PROC MEANS is only worthwhile if you are using NWAY to get the lowest level or only one level of stats. Otherwise the cure is worse than the disease....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that if you are wanting to run this on a non-SAS database, SAS will translate the MEANS code into SQL automatically.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 21:24:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Means-to-SQL-code/m-p/213930#M52747</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2015-05-13T21:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Means to SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Means-to-SQL-code/m-p/213931#M52748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Proc Means is one of the procedures that are enhanced for in-database processing so may be translating the logic into SQL won't give you anything else than more work and higher complexity code.&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/67327/HTML/default/viewer.htm#p0rbwzwi5gyyxwn1irfgkjgprt1p.htm" title="http://support.sas.com/documentation/cdl/en/proc/67327/HTML/default/viewer.htm#p0rbwzwi5gyyxwn1irfgkjgprt1p.htm"&gt;http://support.sas.com/documentation/cdl/en/proc/67327/HTML/default/viewer.htm#p0rbwzwi5gyyxwn1irfgkjgprt1p.htm&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haven't tried it but it's worth a shot: You could define below options before running your Proc Means code. Proc Means being an in-database enhanced procedures SAS will try to convert the proc syntax into SQL code and send it to the database. The options below will show you the SQL code generated in the SAS log. This will show you if SAS could translate the Proc Means code fully into SQL and if you still want to go for a SQL replacement then the code generated would also be a very good starting point for you (just copy/paste it).&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #545454; font-family: arial, sans-serif; font-size: small; background-color: #ffffff;"&gt;OPTIONS SASTRACE=',,,d' SASTRACELOC=SASLOG &lt;/SPAN&gt;&lt;SPAN style="font-weight: bold; color: #6a6a6a; font-family: arial, sans-serif; font-size: small; background-color: #ffffff;"&gt;NOSTSUFFIX&lt;/SPAN&gt;&lt;SPAN style="color: #545454; font-family: arial, sans-serif; font-size: small; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 21:39:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Means-to-SQL-code/m-p/213931#M52748</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-05-13T21:39:33Z</dc:date>
    </item>
  </channel>
</rss>

