<?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: Question about %Let in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/264039#M3909</link>
    <description>&lt;P&gt;And in addition to %EVAL for doing integer math, %sysfunc() allows you to call many data step functions within the macro language, including INTNX and MDY for date calculations.&amp;nbsp; So it's possible (and sometimes useful) to use the macro language for this sort of calculation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below code uses INTNX() to compute the SAS date of the next month, and formats that as yymmn6.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%LET ANNO = 2016;
%LET MESE = 2;

%let MOLOG_SUC = MOLOGATM%sysfunc(intnx(month
                                       ,%sysfunc(mdy(&amp;amp;mese,1,&amp;amp;anno))
                                       ,1)
                                 ,yymmn6.
                                  ); 
%put &amp;amp;MOLOG_SUC; &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That will return:&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MOLOGATM201603&lt;/P&gt;</description>
    <pubDate>Thu, 14 Apr 2016 23:27:39 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2016-04-14T23:27:39Z</dc:date>
    <item>
      <title>Question about %Let</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/263802#M3898</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have this var:&lt;/P&gt;
&lt;P&gt;%LET YEAR = 2016;&lt;/P&gt;
&lt;P&gt;%LET MONTH = 2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have to get a var of the next month:&lt;/P&gt;
&lt;P&gt;%LET MONTH_NEXT = &amp;amp;MONTH+1; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;(MONTH_NEXT) PUT -&amp;gt; 2 + 1&amp;nbsp;&amp;nbsp; (wrong – I need the result is 3)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what is my error ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 09:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/263802#M3898</guid>
      <dc:creator>Cello23</dc:creator>
      <dc:date>2016-04-14T09:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Question about %Let</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/263803#M3899</link>
      <description>&lt;P&gt;Why are you processing "data" in macro? &amp;nbsp;Macro is a tool for generating text, it is not a "data" manipulation language, that is what Base SAS is for.&lt;/P&gt;
&lt;PRE&gt;data temp;
  year=2016;
  month=2;
  day=1;
  result=month(intnx('month',mdy(month,day,year),1));
  put _all_;
run;&lt;/PRE&gt;
&lt;P&gt;You will note the use of Base SAS functions to move dates by intervals.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 09:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/263803#M3899</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-14T09:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Question about %Let</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/263809#M3900</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET ANNO = 2016;
%LET MESE = 2;
%LET DT_INIZIO = '28MAR2016'D;
%LET DT_FINE = '01APR2016'D;

%LET MESE_SUC = &amp;amp;MESE+1;
%LET MOLOG = MOLOGATM&amp;amp;ANNO&amp;amp;MESE;
% LET MOLOG_SUC = MOLOGATM&amp;amp;ANNO&amp;amp;MESE_SUC; 

%syslput ANNO=&amp;amp;ANNO;
%syslput MESE=&amp;amp;MESE;
%syslput MOLOG = &amp;amp;MOLOG;
%syslput MOLOG_SUC = &amp;amp;MOLOG_SUC;
%syslput DT_INIZIO = &amp;amp;DT_INIZIO;
%syslput DT_FINE = &amp;amp;DT_FINE;

 
rsubmit UNIX_601;
libname UNI clear;
libname UNI DB2 user=&amp;amp;user_ora PW=&amp;amp;pw_ora db=&amp;amp;db schema=UNI defer=yes CONNECTION=GLOBALREAD UTILCONN_TRANSIENT=YES;;
PROC SQL;
CREATE TABLE T01 AS 
SELECT B.CO_ATM, B.CODCAB, B.DB_OPER, B.CO_CAU_OPER_ATM, B.CO_SUB_CAU_OPE_ATM, B.FL_CARTA_BANCA, 
SUM(B.MAX_PREL) AS MAX_PREL, SUM( B.IM_OPER_ATM) AS IMP, COUNT (*) AS N 
FROM (
SELECT A.CO_ATM, A.CODCAB, A.DB_OPER, A.CO_CAU_OPER_ATM, A.CO_SUB_CAU_OPE_ATM, A.FL_CARTA_BANCA, 
(CASE WHEN IM_OPER_ATM &amp;gt;750 then 1 else 0 end )AS MAX_PREL, A.IM_OPER_ATM
FROM UNI.&amp;amp;MOLOG A
WHERE A.DT_OPE BETWEEN &amp;amp;DT_INIZIO AND &amp;amp;DT_FINE
/* AND CO_ATM = '00001'
AND CODCAB = '11717' */
UNION ALL
SELECT A.CO_ATM, A.CODCAB, A.DB_OPER, A.CO_CAU_OPER_ATM, A.CO_SUB_CAU_OPE_ATM, A.FL_CARTA_BANCA, /* PRENDO DENTRO ANCHE IL MESE SUCCESSIVO, IN QUESTO MODO SE HO UNA SETTIMANA CHE SCAVALLA RICAVA DA SUBITO IL DATO COMPLETO */
(CASE WHEN IM_OPER_ATM &amp;gt;750 then 1 else 0 end )AS MAX_PREL, A.IM_OPER_ATM
FROM UNI.&amp;amp;MOLOG_SUC A
WHERE A.DT_OPE BETWEEN &amp;amp;DT_INIZIO AND &amp;amp;DT_FINE
/* AND CO_ATM = '00001'
AND CODCAB = '11717' */

) AS B
GROUP BY B.CO_ATM, B.CODCAB, B.DB_OPER, B.CO_CAU_OPER_ATM, B.CO_SUB_CAU_OPE_ATM, B.FL_CARTA_BANCA 
;
quit;
libname UNI clear;
endrsubmit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is the complete code.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 10:05:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/263809#M3900</guid>
      <dc:creator>Cello23</dc:creator>
      <dc:date>2016-04-14T10:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Question about %Let</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/263810#M3901</link>
      <description>&lt;P&gt;Replace&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET MESE_SUC = &amp;amp;MESE+1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
suc_month = month(intnx('month',mdy(&amp;amp;mese,1,&amp;amp;anno),1));
call symput('mese_suc',put(suc_month,2.));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Apr 2016 10:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/263810#M3901</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-04-14T10:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Question about %Let</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/263812#M3902</link>
      <description>&lt;P&gt;Having applied some formatting, indentation, consitent casing, finishing macro variables, and correcting a few typos, I have the below, which I have added the data _null_ call:&lt;/P&gt;
&lt;PRE&gt;%let anno=2016;
%let mese=2;
%let dt_inizio='28mar2016'd;
%let dt_fine='01apr2016'd;

data _null_;
  call symput('molog',cats("MOLOGATM",put(&amp;amp;anno.,z4.),put(&amp;amp;messe.,z2.)));
  call symput('molog_suc',cats("MOLOGATM",put(year(intnx('month',mdy(&amp;amp;anno.,&amp;amp;messe.,1),1)),z4.),put(month(z2.)));
run;

rsubmit unix_601;
libname uni clear;
libname uni db2 user=&amp;amp;user_ora. pw=&amp;amp;pw_ora. db=&amp;amp;db. schema=uni defer=yes connection=globalread utilconn_transient=yes;

proc sql;
  create table T01 as 
  select  B.CO_ATM, 
          B.CODCAB, 
          B.DB_OPER, 
          B.CO_CAU_OPER_ATM, 
          B.CO_SUB_CAU_OPE_ATM, 
          B.FL_CARTA_BANCA, 
          sum(B.MAX_PREL) as MAX_PREL, 
          sum(B.IM_OPER_ATM) as IMP, 
          count(*) as N 
  from    (
            select  A.CO_ATM, 
                    A.CODCAB, 
                    A.DB_OPER, 
                    A.CO_CAU_OPER_ATM, 
                    A.CO_SUB_CAU_OPE_ATM, 
                    A.FL_CARTA_BANCA, 
                    case when IM_OPER_ATM &amp;gt;750 then 1 else 0 end as MAX_PREL, 
                    A.IM_OPER_ATM
            from    UNI.&amp;amp;MOLOG. A
            where   A.DT_OPE between &amp;amp;DT_INIZIO. and &amp;amp;DT_FINE.
            union all
            select  A.CO_ATM, 
                    A.CODCAB, 
                    A.DB_OPER, 
                    A.CO_CAU_OPER_ATM, 
                    A.CO_SUB_CAU_OPE_ATM, 
                    A.FL_CARTA_BANCA, 
                    case when IM_OPER_ATM &amp;gt; 750 then 1 else 0 end as MAX_PREL, 
                    A.IM_OPER_ATM
            from    UNI.&amp;amp;MOLOG_SUC. A
            where   A.DT_OPE between &amp;amp;DT_INIZIO. and &amp;amp;DT_FINE.
          ) as B
  group by  B.CO_ATM, 
            B.CODCAB, 
            B.DB_OPER, 
            B.CO_CAU_OPER_ATM, 
            B.CO_SUB_CAU_OPE_ATM, 
            B.FL_CARTA_BANCA;
quit;

libname uni clear;
endrsubmit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have no way of testing it however.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 10:24:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/263812#M3902</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-14T10:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: Question about %Let</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/263819#M3903</link>
      <description>&lt;P&gt;Macro language does not perform math automatically. &amp;nbsp;You have to tell it to perform the math by adding a function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let month_next = %eval(&amp;amp;month + 1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's not to contradict any of the other posts ... that's just to answer the question the way it was posed originally.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 11:41:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/263819#M3903</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-14T11:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: Question about %Let</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/263850#M3905</link>
      <description>&lt;P&gt;I have this error:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: File UNI.MOLOGATM20162.DATA does not exist.
ERROR: File UNI.A.DATA does not exist.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
690      quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.02 seconds
      cpu time            0.00 seconds

691
692    libname UNI clear;
NOTE: Libref UNI has been deassigned.
NOTE: Remote submit to UNIX_601 complete.
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%LET ANNO = 2016;
%LET MESE = 2;
%LET DT_INIZIO =  '28MAR2016'D;
%LET DT_FINE   =  '01APR2016'D;


	  data _null_;
	  call symput('molog',cats(put(&amp;amp;anno.,z4.),put(&amp;amp;mese.,z2.)));
	  call symput('molog_suc',cats(put(year(intnx('month',mdy(&amp;amp;anno.,&amp;amp;MESE.,1),1)),z4.),put(month(z2.)));
	 run;

 

rsubmit UNIX_601;
 libname UNI clear;
	libname UNI DB2 user=&amp;amp;user_ora PW=&amp;amp;pw_ora db=&amp;amp;db schema=UNI defer=yes CONNECTION=GLOBALREAD UTILCONN_TRANSIENT=YES;;

	PROC SQL;
	CREATE TABLE  T01 AS  
	SELECT B.CO_ATM, B.CODCAB,  B.DB_OPER, B.CO_CAU_OPER_ATM, B.CO_SUB_CAU_OPE_ATM, B.FL_CARTA_BANCA, 
	SUM(B.MAX_PREL) AS MAX_PREL, SUM( B.IM_OPER_ATM) AS IMP, COUNT (*) AS N 
	FROM (

		SELECT A.CO_ATM, A.CODCAB,  A.DB_OPER, A.CO_CAU_OPER_ATM, A.CO_SUB_CAU_OPE_ATM, A.FL_CARTA_BANCA, 
		(CASE WHEN IM_OPER_ATM &amp;gt;750 then  1 else  0 end  )AS MAX_PREL, A.IM_OPER_ATM
		FROM UNI.&amp;amp;MOLOG A
		WHERE A.DT_OPE BETWEEN &amp;amp;DT_INIZIO AND &amp;amp;DT_FINE
		/* AND CO_ATM = '00001'
		AND CODCAB = '11717' */

		UNION ALL

		SELECT A.CO_ATM, A.CODCAB,  A.DB_OPER, A.CO_CAU_OPER_ATM, A.CO_SUB_CAU_OPE_ATM, A.FL_CARTA_BANCA,  /* PRENDO DENTRO ANCHE IL MESE SUCCESSIVO, IN QUESTO MODO SE HO UNA SETTIMANA CHE SCAVALLA RICAVA DA SUBITO IL DATO COMPLETO */
		(CASE WHEN IM_OPER_ATM &amp;gt;750 then  1 else  0 end  )AS MAX_PREL, A.IM_OPER_ATM
		FROM UNI.&amp;amp;MOLOG_SUC A
		WHERE A.DT_OPE BETWEEN &amp;amp;DT_INIZIO AND &amp;amp;DT_FINE
		/* AND CO_ATM = '00001'
		AND CODCAB = '11717' */


	) AS B

 	GROUP BY B.CO_ATM, B.CODCAB, B.DB_OPER, B.CO_CAU_OPER_ATM, B.CO_SUB_CAU_OPE_ATM, B.FL_CARTA_BANCA 
	;
	quit;

  libname UNI clear;
endrsubmit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 12:53:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/263850#M3905</guid>
      <dc:creator>Cello23</dc:creator>
      <dc:date>2016-04-14T12:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: Question about %Let</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/263859#M3906</link>
      <description>&lt;P&gt;Well typo on my part there - note I can't test this:&lt;/P&gt;
&lt;PRE&gt;data _null_;
 call symput('molog',cats("MOLOGATM",put(&amp;amp;anno.,z4.),put(&amp;amp;messe.,z2.)));
 new_date=intnx('month',mdy(&amp;amp;anno.,&amp;amp;messe.,1),1)
 call symput('molog_suc',cats("MOLOGATM",put(year(new_date),z4.),put(month(new_date),z2.)));
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 13:14:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/263859#M3906</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-14T13:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Question about %Let</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/264039#M3909</link>
      <description>&lt;P&gt;And in addition to %EVAL for doing integer math, %sysfunc() allows you to call many data step functions within the macro language, including INTNX and MDY for date calculations.&amp;nbsp; So it's possible (and sometimes useful) to use the macro language for this sort of calculation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below code uses INTNX() to compute the SAS date of the next month, and formats that as yymmn6.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%LET ANNO = 2016;
%LET MESE = 2;

%let MOLOG_SUC = MOLOGATM%sysfunc(intnx(month
                                       ,%sysfunc(mdy(&amp;amp;mese,1,&amp;amp;anno))
                                       ,1)
                                 ,yymmn6.
                                  ); 
%put &amp;amp;MOLOG_SUC; &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That will return:&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MOLOGATM201603&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 23:27:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/264039#M3909</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2016-04-14T23:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: Question about %Let</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/264111#M3910</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%LET YEAR = 2016;
%LET MONTH = 12;
 

%LET MONTH_NEXT = %eval(%sysfunc(mod(&amp;amp;MONTH,12))+1); 

%put NOTE: &amp;amp;MONTH_NEXT ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Apr 2016 07:53:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/264111#M3910</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-15T07:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Question about %Let</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/265610#M3937</link>
      <description>thanks!!!!</description>
      <pubDate>Fri, 22 Apr 2016 09:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/265610#M3937</guid>
      <dc:creator>Cello23</dc:creator>
      <dc:date>2016-04-22T09:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: Question about %Let</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/265611#M3938</link>
      <description>thanks</description>
      <pubDate>Fri, 22 Apr 2016 09:09:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Question-about-Let/m-p/265611#M3938</guid>
      <dc:creator>Cello23</dc:creator>
      <dc:date>2016-04-22T09:09:54Z</dc:date>
    </item>
  </channel>
</rss>

