DATA Step, Macro, Functions and more

Call SymputX Issue

Posts: 36

Call SymputX Issue

In the following code, the macro-variables :
Annee, Mois, Periode and FicOk have no value affected at the first run of the code.

Annee, Mois, Periode are affected at the second run and FicOk at the third time.

How could I do to make the programme run at the first time ?


%Macro CreeTableMensuelle(MyTableRef, MyLibIn, MyTableOut, MyAnnee, MyMois, MyPeriode);
%Global PrefD;
%Global PrefC;
%Global PostRep;

%Global stRep;
%Global stFichier;

%Global Annee;
%Global Mois;
%Global Periode;
%Global FicOk;

%Global Nom;

/* Préfixe pour tables de données : Les tables s'appellent D_ suivi du nom du fichier d'origine */
%Let PrefD=D_;

/* Préfixe pour table de tests de contraintes */
%let prefC=C_;

/* PostFixe pour répertoire de tables à traiter (nom de la feuille de l'arborescence) */
%Let PostRep=A_TRAITER;

/* On parcourt la table MyTableRef */
Data _NULL_;
Set &MyTableRef;

/* Si l'enregistrement courant présente les bonnes condition alors on ajoute */
/* Le fichier qu'il désigne à MyTableOut */
Call SymputX('Annee',input(Annee,best.));
Call SymputX('Mois',input(Mois,best.));
Call SymputX('Periode',Periode);
Call SymputX('FicOk',input(FicOk,best.));

%If &Annee eq &MyAnnee and &Mois eq &MyMois and &Periode eq &MyPeriode and &FicOk eq 1 %Then %Do;

/* Constitution du répertoire physique où se situe la table */
/* des données à intégrer à la table mensuelle des données */
%If &MyPeriode eq A %Then %Let stRep=&MyLibIn.\&MyAnnee.\&MyMois.\ANNUEL;
%If &MyPeriode eq M %Then %Let stRep=&MyLibIn.\&MyAnnee.\&MyMois.\MENSUEL;

Libname LibSrc "&stRep.\&PostRep";
%put &stRep.\&PostRep;

/* Nom de la table à intégrer */
Call SymputX('Nom',Fichier);
%Let stFichier=&PrefD.&Nom;
%put MyTableRef = &MyTableRef - stFichier = &stFichier;

/* Ajout de la table à MyTableOut */

/* Constitution du nom de la table des tests à intégrer à la table mensuelle des tests */


Super Contributor
Super Contributor
Posts: 3,174

Re: Call SymputX Issue

The SAS program you shared is invoking a SAS macro which you have not provided in your post, that is IntegreTabl.

Also, you are mixing SAS macro language and DATA step CALL SYMPUTX - the CALL function creates SAS global macro variables but it occurs during DATA step execution and not SAS macro compilation, normally.

And, you have a SAS LIBNAME statement in the middle of what appears to be a DATA step execution.

You must create SAS global macro variables using %LET statements, before the macro CreeTableMensuelle is executed.

Below, you will find a suggested SAS support website search argument, which will generate some links for your review and reading on this subject-matter.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic/post:

macro variable focus symput global
Regular Contributor
Posts: 165

Re: Call SymputX Issue

I am not a macro expert but I believe the problem might be that when you use "call symputx" you cannot use the same macro within the data step. You might need to use a couple of data _NULL_ steps and make sure you end them with run;
Posts: 36

Re: Call SymputX Issue

Thank you for your answers.
I will have a look at this.

Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation