<?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: Utilisation de macro variables pour INTNX : ne me retourne rien in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Utilisation-de-macro-variables-pour-INTNX-ne-me-retourne-rien/m-p/260089#M57512</link>
    <description>&lt;P&gt;Sorry, but my school french is a bit rusty. Is it possible for you to translate&amp;nbsp;your question to English?&lt;/P&gt;
&lt;P&gt;If there's a need for submitting posts in french, try to convince your SAS office to start a french speaking forum. This&amp;nbsp;already exists for German&amp;nbsp;and Danish.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Mar 2016 14:00:48 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2016-03-30T14:00:48Z</dc:date>
    <item>
      <title>Utilisation de macro variables pour INTNX : ne me retourne rien</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Utilisation-de-macro-variables-pour-INTNX-ne-me-retourne-rien/m-p/260059#M57510</link>
      <description>&lt;P&gt;Bonjour,&lt;/P&gt;&lt;P&gt;Je rencontre actuellement un problème sous SAS et j'avoue que cela fait un bout de temps que je n'en ai pas fait...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mon problème est le suivant :&lt;/P&gt;&lt;P&gt;1) je souhaite sauvegarder dans date_debut_douverture la date "01sep2013"d &amp;nbsp; : OK cela fonctionne&lt;/P&gt;&lt;P&gt;2) je souhaite calculer date_i = date_debut_douverture + i mois (via la fonction intnx : PB cela me retourne " " et non pas "01oct2013"d, "01nov2013"d etc, je n'ai pas d'avertissement sous SAS&lt;/P&gt;&lt;P&gt;3) je souhaiterais ensuite calculer date_table_i pour avoir respectivement un NOMBRE correspondant à YYMM : 1310, 1311, 1312, 1401 etc : PB ça ne fonctionne pas vu que l'étape 2 ne fonctionne pas... Cette variable me permettra ensuite de faire appel à un table de type WORK.A_1310, WORK.A_1311...&lt;/P&gt;&lt;P&gt;J'ai absolument besoin&amp;nbsp;des deux variables date_i et date_table_i (date_i me servira pour d'autres fonctions que je n'ai pas mise dans mon code).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Voici mon script :&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%global date_debut_ouverture ;
%let date_debut_ouverture = "01sep2013"d;

/*MACRO pour calculer date_debut_ouverture + i mois*/
%macro calcul_date(nbmois);
    %do i=1 %to &amp;amp;nbmois;
        %global date_&amp;amp;i date_table_&amp;amp;i ;
        %let date_&amp;amp;i = %SYSFUNC(intnx("month", &amp;amp;date_debut_ouverture, &amp;amp;i, 'same'),date9.);
        %let date_table_&amp;amp;i = %SYSFUNC(putn(&amp;amp;date_&amp;amp;i.,yymmn4.),yymmn4.);      /*je pense qu'il manque tout de même l'étape où il y a la transformation de la date en chiffre */
    %end;
%mend calcul_date;
%calcul_date(24);
 

/*on lit les tables WORK.A_YYMM etc. */ 
%Macro fonction_table(YYMM);
  proc sql ; 
	create table work.sortie as select *
	FROM work.A_&amp;amp;YYMM ;
  quit ; 
%Mend fonction_table;

%fonction_table(&amp;amp;date_table_1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Je vous remercie par avance de votre aide, et vous souhaite une bonne journée &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alison&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 12:57:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Utilisation-de-macro-variables-pour-INTNX-ne-me-retourne-rien/m-p/260059#M57510</guid>
      <dc:creator>alisondu77</dc:creator>
      <dc:date>2016-03-30T12:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Utilisation de macro variables pour INTNX : ne me retourne rien</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Utilisation-de-macro-variables-pour-INTNX-ne-me-retourne-rien/m-p/260086#M57511</link>
      <description>&lt;P&gt;Not sure why you would want to do all that "data" processing in macro language. &amp;nbsp;Datastep is designed to manipulate and process data for example has date types, macro just generates datastep code. &amp;nbsp;Something like:&lt;/P&gt;
&lt;PRE&gt;%let date_debut_ouverture="01SEP2013"d;
%let nbmois=24;

data _null_;
  do i=1 to &amp;amp;nbmois;
    call symput(cats('date',i),put(intnx("month",&amp;amp;date_debut_overture.,i,'same'),date9.));
  end;
run;&lt;/PRE&gt;
&lt;P&gt;However I would suggest two things. &amp;nbsp;First its not a good idea to put data - in this case month and year - as dataset names. &amp;nbsp;Append your data together, and create a column of data from that:&lt;/P&gt;
&lt;PRE&gt;data total;
  set work.a_: indsname=nme;
  year_month=strip(tranwrd(nme,"A_",""));
run;&lt;/PRE&gt;
&lt;P&gt;With the above, you then have one dataset, which you can process once, avoiding looping over many datasets, and if needed, you can split them up later on. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Secondly, instead of making lots of macro variables, and then using them on lots of different datasets, you can set your range into a dataset and use simple merging:&lt;/P&gt;
&lt;PRE&gt;data range;
  do year=2013 to 2015;
    do month=1 to 12;
      year_month=cats(substr(put(year,z4.),3,2),put(month,z2.));
      output;
    end;
  end;
run;

proc sql;
  create table WANT as
  select  *
  from    TOTAL
  where  YEAR_MONTH in (select YEAR_MONTH from RANGE);
quit;
&lt;/PRE&gt;
&lt;P&gt;Simpler coding. &amp;nbsp;Also allows you to use "by group" processing, which is quicker and better on resources than doing each group indivisually.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 13:59:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Utilisation-de-macro-variables-pour-INTNX-ne-me-retourne-rien/m-p/260086#M57511</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-30T13:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: Utilisation de macro variables pour INTNX : ne me retourne rien</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Utilisation-de-macro-variables-pour-INTNX-ne-me-retourne-rien/m-p/260089#M57512</link>
      <description>&lt;P&gt;Sorry, but my school french is a bit rusty. Is it possible for you to translate&amp;nbsp;your question to English?&lt;/P&gt;
&lt;P&gt;If there's a need for submitting posts in french, try to convince your SAS office to start a french speaking forum. This&amp;nbsp;already exists for German&amp;nbsp;and Danish.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 14:00:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Utilisation-de-macro-variables-pour-INTNX-ne-me-retourne-rien/m-p/260089#M57512</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-03-30T14:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: Utilisation de macro variables pour INTNX : ne me retourne rien</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Utilisation-de-macro-variables-pour-INTNX-ne-me-retourne-rien/m-p/260328#M57540</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;Sorry my English is poor but thank you for your complete and quick answers.&lt;/P&gt;&lt;P&gt;I can’t change my dataset, I have millions of data in each sets. So I have to use the name of the sets “work.A_YYMM” to do my work. And it’s forbidden to me to change the datasets &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; sorry.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will try to explain you what I&amp;nbsp;want to do :&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I save “01sept2013” in a variable : date_debut_ouverture : OK it’s work&lt;/LI&gt;&lt;LI&gt;Then I would like to calculate for i from 1 to 24 : date_debut_ouverture + I * month (save in the variable date_i). That’s to say I would like : &amp;nbsp; &amp;nbsp;&amp;nbsp;Date_1 = ‘01oct2013 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Date_2 = ’01nov2013’ &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;Date_24 = ‘01aug2015’.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;To do this I choose the function : intnx --&amp;gt;&amp;nbsp;(%let date_&amp;amp;i = %SYSFUNC(intnx("month", &amp;amp;date_debut_ouverture, &amp;amp;i, 'same'),date9.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; But when I want to see the result, I have ‘ ‘ (so nothing). And I didn’t understand why and I have no errors in my log.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Then I would like to use the variable date_i, to transform it in a number which represent YYMM (save in the variable date_table_i), so for example : &amp;nbsp; &amp;nbsp;&amp;nbsp;Date_table_1 = 1310 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Date_table_2 = 1311 … &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Date_table_4 = 1508&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I didn’t go so far in this point, because of the previous step (2) that didn’t work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to do with this, is to use date_table_i to call sets&amp;nbsp;which looks like “A_YYMM”, and to use date_i for some sections where in some others proc sql like (where date=&amp;amp;date_i).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again, and have a good day !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alison&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2016 07:02:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Utilisation-de-macro-variables-pour-INTNX-ne-me-retourne-rien/m-p/260328#M57540</guid>
      <dc:creator>alisondu77</dc:creator>
      <dc:date>2016-03-31T07:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: Utilisation de macro variables pour INTNX : ne me retourne rien</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Utilisation-de-macro-variables-pour-INTNX-ne-me-retourne-rien/m-p/260346#M57542</link>
      <description>&lt;P&gt;Well, I am unsure as to why you would have a restriction on what you do in your working area. &amp;nbsp;In the code you post, you are creating datasets with different names:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;	create &lt;SPAN class="token statement"&gt;table&lt;/SPAN&gt; work&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;sortie as &lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am not suggesting changing your source data, only your copy of it. Anyways, going back to the first part of my post, you can do your calculation in a datastep and then push it out to the macro varaible. &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let date_debut_ouverture="01SEP2013"d;&lt;BR /&gt;%let nbmois=1;&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt; do i=1 to &amp;amp;nbmois;&lt;BR /&gt; dt=intnx("month",&amp;amp;date_debut_ouverture.,i,'same');&lt;BR /&gt; ym=put(year(dt),z4.)||put(month(dt),z2.);&lt;BR /&gt; call symput(cats('date',i),ym);&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%put &amp;amp;date1;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;What this will do is to create one macro variable, each called dateX - X being the incrementor. &amp;nbsp;You can then use that further in your code:&lt;/P&gt;
&lt;PRE&gt;%fonction_table(&amp;amp;date1.);
&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Mar 2016 09:04:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Utilisation-de-macro-variables-pour-INTNX-ne-me-retourne-rien/m-p/260346#M57542</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-31T09:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: Utilisation de macro variables pour INTNX : ne me retourne rien</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Utilisation-de-macro-variables-pour-INTNX-ne-me-retourne-rien/m-p/260374#M57543</link>
      <description>&lt;P&gt;Ohhhhh thank you so much ! It works very well ! Thank you, I was disappointed not to find the solution !&lt;/P&gt;&lt;P&gt;I made a little transformation of the solution to fit correctly on my datasets.&lt;/P&gt;&lt;P&gt;And you were right about the 'restriction', but it's because i simplify the code and so, it seems weird and like there are&amp;nbsp;no restrictions &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So this is the final version (with comment in French sorry &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%global date_debut_ouverture nbmois;
%let date_debut_ouverture = "01sep2013"d;
%let nbmois = 24 ;

/*MACRO pour calculer date_debut_ouverture + i mois*/
data _null_;
 do i=1 to &amp;amp;nbmois;
 dt=intnx("month",&amp;amp;date_debut_ouverture.,i,'same');					/* date_debut_ouverture + i mois */
 dt_bis = put(dt,date9.) ;											/* dt sous format 01oct2013*/
 ym=substr(put(year(dt),z4.),3)||put(month(dt),z2.);				/* ym = 1310 (format 'YYMM') */
 call symput(cats('date_table_',i),ym);								/* enregistrement dans date_table_i = ym */
 call symput(cats('date_',i),dt_bis);								/* enregistrement dans date__i = dt */
 end;
run;
 

/*on lit les tables WORK.A_YYMM etc. */ 
%Macro fonction_table(YYMM);
  proc sql ; 
	create table work.sortie as select *
	FROM work.A_&amp;amp;YYMM ;												/* lecture de la table : work.A_1310 */
  quit ; 
%Mend fonction_table;

%fonction_table(&amp;amp;date_table_1);										

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again !!! &amp;nbsp;Super answer !!! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Have a good day RW9 &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2016 12:11:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Utilisation-de-macro-variables-pour-INTNX-ne-me-retourne-rien/m-p/260374#M57543</guid>
      <dc:creator>alisondu77</dc:creator>
      <dc:date>2016-03-31T12:11:39Z</dc:date>
    </item>
  </channel>
</rss>

