<?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 SQL macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202456#M37776</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The log helps!&amp;nbsp; It looks like you never actually call the macro. &lt;/P&gt;&lt;P&gt;Would expect to see:&lt;/P&gt;&lt;P&gt;&amp;nbsp; %SQLLOOP;&lt;/P&gt;&lt;P&gt;to call the macro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Jul 2015 17:22:40 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2015-07-14T17:22:40Z</dc:date>
    <item>
      <title>PROC SQL macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202449#M37769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;For anyone that can help I'm trying to run a data set that contains the following through PROC SQL to calculate differences between each month for across all years by station and season &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;and make sure I output all variables back into the output data set. I think I have some code that should do it but when I run it the data set I try to merge together comes up empty.&amp;nbsp; Short of generating the code for me does anyone have any clues what I'm doing wrong here? The code runs with no error messages at all. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Note &amp;amp;NYR is a global macro variable set to 10 elsewhere in the program as follows for example:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;%LET &amp;amp;NYR=10; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Here's the variables in the input data - all numeric except station, season and _name_:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;DATA SKDATA;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;STATION SEASON&amp;nbsp; MONTH&amp;nbsp; _NAME_ NYEARS _2003 _2004 _2005 _2006 _2007 _2008 _2009 _2010 _2011 _2012 Y_2003 Y_2004 Y_2005 Y_2006 Y_2007 Y_2008 Y_2009 Y_2010 Y_2011 Y_2012 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Here is the code: Any assistance would help.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;%MACRO SQLLOOP;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%DO I=0 %TO &amp;amp;NYR;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;CREATE TABLE SENSLOPE&amp;amp;I AS&lt;/P&gt;&lt;P&gt;SELECT STATION, SEASON, MONTH, _%EVAL(&amp;amp;STY.+&amp;amp;I), _%EVAL(&amp;amp;STY.+&amp;amp;I+1]), Y_%EVAL(&amp;amp;STY.+&amp;amp;I+1), Y_%EVAL(&amp;amp;STY.+&amp;amp;I), _%EVAL(&amp;amp;STY.+&amp;amp;I) - _%EVAL(&amp;amp;STY.+&amp;amp;I+1]) AS D_%EVAL(&amp;amp;STY.+&amp;amp;I+1),&lt;/P&gt;&lt;P&gt;Y_%EVAL(&amp;amp;STY.+&amp;amp;I+1) - Y_%EVAL(&amp;amp;STY.+&amp;amp;I) AS DY_%EVAL(&amp;amp;STY.+&amp;amp;I+1)&lt;/P&gt;&lt;P&gt;FROM SKDATA&lt;/P&gt;&lt;P&gt;GROUP BY STATION, SEASON, MONTH;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;%END;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA SENSLOPE;MERGE SENSLOPE0-SENSLOPE&amp;amp;NYR; BY STATION SEASON MONTH;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%MEND SQLLOOP;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;RUN;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 16:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202449#M37769</guid>
      <dc:creator>kodmfl</dc:creator>
      <dc:date>2015-07-14T16:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202450#M37770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The first %LET statement should be %let NYR=10.&amp;nbsp; NOT %let &amp;amp;NYR=10.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you turn on options mprint, what do you see in the log after calling the macro?&amp;nbsp; That should show what datasets were created, and how many observations they have.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 16:57:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202450#M37770</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2015-07-14T16:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202451#M37771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried that and believe it or not I am not getting anything which I don't understand ...and which is why I'm here hat in hand as it were.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 17:00:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202451#M37771</guid>
      <dc:creator>kodmfl</dc:creator>
      <dc:date>2015-07-14T17:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202452#M37772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Without seeing the data I suspect the first thing "wrong" is having the data in the "wide" form of years.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where does &amp;amp;STY come from? What is its value?(I would guess 2002)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you exam for instance the content of&amp;nbsp; SENSLOPE0 and SENSLOPE1?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did this evolve from a process that wasn't a macro, something that worked for maybe two years ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 17:00:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202452#M37772</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-07-14T17:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202453#M37773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah I meant &lt;SPAN style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: #333333;"&gt;NYR=10 actually&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 17:01:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202453#M37773</guid>
      <dc:creator>kodmfl</dc:creator>
      <dc:date>2015-07-14T17:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202454#M37774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried arrays instead of macros? I think it would work well in this case...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 17:03:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202454#M37774</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-07-14T17:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202455#M37775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure what you mean by "wide" form of years? Anyway &amp;amp;sty is the starting year in this case 2003 so the first variable is _2003 next column _2004, and so on. Variable contents are numeric values of water quality parameters and take values that can range from very small say 0.001 to 1.000 or much higher 1.0 to 500.0 depending on the parameter. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did this evolve from a process that wasn't a macro, something that worked for maybe two years ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually no, this was already a macro that I wanted to try and redo using PROC SQL. I think although I can't prove it yet, that by using the BY statement processing of PROC SQL I can reduce the processing time for the macro that was developed previously. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think there's something wrong with the SQL select statement because&amp;nbsp; I'm getting no warnings no errors just 0 obs. Here's the log. I may have to use more than one select statement. I think it's have trouble with the %EVALs in combination with the commas required in PROC SQL but I don' know. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; "SKDATA" range/sheet was successfully created.&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE EXPORT used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.14 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.15 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;34000&lt;/P&gt;&lt;P&gt;34001&amp;nbsp; %MACRO SQLLOOP;&lt;/P&gt;&lt;P&gt;34002&amp;nbsp; %DO I=0 %TO 10;&lt;/P&gt;&lt;P&gt;34003&amp;nbsp; PROC SQL;&lt;/P&gt;&lt;P&gt;34004&amp;nbsp; CREATE TABLE SENSLOPE&amp;amp;I AS&lt;/P&gt;&lt;P&gt;34005&amp;nbsp; SELECT STATION, SEASON, MONTH, _%EVAL(&amp;amp;STY.+&amp;amp;I), _%EVAL(&amp;amp;STY.+&amp;amp;I+1]), Y_%EVAL(&amp;amp;STY.+&amp;amp;I+1),&lt;/P&gt;&lt;P&gt;34005! Y_%EVAL(&amp;amp;STY.+&amp;amp;I), _%EVAL(&amp;amp;STY.+&amp;amp;I) - _%EVAL(&amp;amp;STY.+&amp;amp;I+1]) AS D_%EVAL(&amp;amp;STY.+&amp;amp;I+1)&lt;/P&gt;&lt;P&gt;34006&amp;nbsp; Y_%EVAL(&amp;amp;STY.+&amp;amp;I+1) - Y_%EVAL(&amp;amp;STY.+&amp;amp;I) AS DY_%EVAL(&amp;amp;STY.+&amp;amp;I+1)&lt;/P&gt;&lt;P&gt;34007&amp;nbsp; FROM SKDATA&lt;/P&gt;&lt;P&gt;34008&amp;nbsp; GROUP BY STATION, SEASON, MONTH;&lt;/P&gt;&lt;P&gt;34009&amp;nbsp; QUIT;&lt;/P&gt;&lt;P&gt;34010&amp;nbsp; %END;&lt;/P&gt;&lt;P&gt;34011&amp;nbsp; PROC PRINT DATA=SENSLOPE0;&lt;/P&gt;&lt;P&gt;34012&amp;nbsp; RUN;&lt;/P&gt;&lt;P&gt;34013&amp;nbsp; PROC PRINT DATA=SENSLOPE1;&lt;/P&gt;&lt;P&gt;34014&amp;nbsp; RUN;&lt;/P&gt;&lt;P&gt;34015&lt;/P&gt;&lt;P&gt;34016&amp;nbsp; DATA SENSLOPE;MERGE SENSLOPE0-SENSLOPE10; BY STATION SEASON MONTH;RUN;&lt;/P&gt;&lt;P&gt;34017&amp;nbsp; RUN;&lt;/P&gt;&lt;P&gt;34018&amp;nbsp; %MEND SQLLOOP;&lt;/P&gt;&lt;P&gt;34019&lt;/P&gt;&lt;P&gt;34020&amp;nbsp; DATA SENSLOPE;SET SENSLOPE;&lt;/P&gt;&lt;P&gt;34021&amp;nbsp; RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: There were 0 observations read from the data set WORK.SENSLOPE.&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.SENSLOPE has 0 observations and 0 variables.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;34022&amp;nbsp; PROC PRINT DATA=SENSLOPE;&lt;/P&gt;&lt;P&gt;34023&amp;nbsp; RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: No variables in data set WORK.SENSLOPE.&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 17:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202455#M37775</guid>
      <dc:creator>kodmfl</dc:creator>
      <dc:date>2015-07-14T17:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202456#M37776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The log helps!&amp;nbsp; It looks like you never actually call the macro. &lt;/P&gt;&lt;P&gt;Would expect to see:&lt;/P&gt;&lt;P&gt;&amp;nbsp; %SQLLOOP;&lt;/P&gt;&lt;P&gt;to call the macro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 17:22:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202456#M37776</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2015-07-14T17:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202457#M37777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Reeza&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually the original code was written using a macro using array statements however I am trying to see if BY statement processing in PROC SQL can reduce processing time on the analyses we are running. The program does many different parameters in combinations of locations and seasons. The macros used for that are fairly complicated and take time to run. I am hoping to use PROC SQL to cut down the run time. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 17:27:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202457#M37777</guid>
      <dc:creator>kodmfl</dc:creator>
      <dc:date>2015-07-14T17:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202458#M37778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Quentin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BAHAHAHAHAAHAHAHA ...ARGHHHH&amp;nbsp; thanks man .... you'll excuse me while I slam my head through my monitor &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 17:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro/m-p/202458#M37778</guid>
      <dc:creator>kodmfl</dc:creator>
      <dc:date>2015-07-14T17:35:01Z</dc:date>
    </item>
  </channel>
</rss>

