<?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: Need help with proc sql and macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-proc-sql-and-macro/m-p/865147#M341642</link>
    <description>&lt;P&gt;There are no macros in your code. There are macro variables. Macros are not macro variables, the two should not be confused.&lt;/P&gt;</description>
    <pubDate>Mon, 20 Mar 2023 09:58:16 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-03-20T09:58:16Z</dc:date>
    <item>
      <title>Need help with proc sql and macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-proc-sql-and-macro/m-p/865128#M341637</link>
      <description>&lt;P&gt;Hello all, I have this code and I want to create 3 different tables using a macro statement. Need some help. I can simply change &amp;amp;type1 to &amp;amp;type2 but what if I got 12 groups, what is an easier way to just do all 3? can I use a %do %to statement?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql number; create table complete_storm as&lt;BR /&gt;select Name,upcase(Basin) as Basin,maxwind,startdate,maxwind*1.60934 as maxwindkm,&lt;BR /&gt;startdate-enddate as stormlength,&lt;BR /&gt;case&lt;BR /&gt;when substr(Basin,2,1) eq "I" then "Indian"&lt;BR /&gt;when substr(Basin,2,1) eq "A" then "Atlantic"&lt;BR /&gt;else "Pacific"&lt;BR /&gt;end as Ocean&lt;BR /&gt;from forth.storm_summary_small&lt;BR /&gt;where Name is not missing;&lt;BR /&gt;quit;&lt;BR /&gt;proc sql;select distinct ocean /* Creating 3 macros */&lt;BR /&gt;into: type1- from complete_storm;quit;&lt;BR /&gt;%put &amp;amp;=type1;%put &amp;amp;=type2;%put &amp;amp;=type3;&lt;/P&gt;&lt;P&gt;proc sql;create table &amp;amp;type1 as&lt;BR /&gt;select * from complete_storm&lt;BR /&gt;where ocean eq "&amp;amp;type1";quit;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 04:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-proc-sql-and-macro/m-p/865128#M341637</guid>
      <dc:creator>Reader587</dc:creator>
      <dc:date>2023-03-20T04:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with proc sql and macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-proc-sql-and-macro/m-p/865131#M341638</link>
      <description>&lt;P&gt;Why do you need to split the data in the first place? You can always use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;by ocean;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(after sorting) in procedure and data steps to do analysis per group.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 06:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-proc-sql-and-macro/m-p/865131#M341638</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-20T06:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with proc sql and macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-proc-sql-and-macro/m-p/865133#M341640</link>
      <description>&lt;P&gt;You can use %DO if you create a variable with a list instead of a list of variables:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select distinct ocean unto :types separated by " "
from complete_storm;
quit;

%macro process_list;
%local i type;
%do i = 1 %to %sysfunc(countw(&amp;amp;list.));
  %let type = %scan(&amp;amp;list.,&amp;amp;i.);
  /* process individual group stored in &amp;amp;type */
%end;
%mend;
%process_list /* call the macro */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but, as already stated, this is not necessary in 99% of cases.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 06:17:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-proc-sql-and-macro/m-p/865133#M341640</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-20T06:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with proc sql and macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-proc-sql-and-macro/m-p/865147#M341642</link>
      <description>&lt;P&gt;There are no macros in your code. There are macro variables. Macros are not macro variables, the two should not be confused.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 09:58:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-proc-sql-and-macro/m-p/865147#M341642</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-20T09:58:16Z</dc:date>
    </item>
  </channel>
</rss>

