BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
alepage
Barite | Level 11

This code works perfectly with EG 7.15 but on the robot   (SAS version ????)

 

%let sysyear= %sysfunc(year("&sysdate"d));
%let Annee=&sysyear;
%let FirstWDay=%sysfunc(NWKDOM(1,2,1,&Annee));
%let FirstWorkingDay=%sysfunc(inputn(&FirstWDay, z8.), date9.);
%let Debut=%sysfunc(compress(%bquote('&FirstWorkingDay'd)));
%put &sysyear;
%put &annee;
%put &firstwday;
%put &firstworkingday;

 

1229 +%let sysyear= %sysfunc(year("&sysdate"d));
Le Système SAS

1230 +
1231 + %if &MotifRapport EQ FINANCIER %THEN
1232 + %DO;
1233 + %let Annee=&sysyear;
1234 + %let FirstWDay=%sysfunc(NWKDOM(1,2,1,&Annee));
1235 + %let FirstWorkingDay=%sysfunc(inputn(&FirstWDay, z8.), date9.);
1236 + %let Debut=%sysfunc(compress(%bquote('&FirstWorkingDay'd)));
1237 + %END;
1238 + %ELSE
1239 + %DO;
1240 + %let Annee=%eval(&sysyear-1);
1241 + %let Debut=%sysfunc(compress(%BQUOTE('31OCT&Annee.'D)));
1242 + %END;
1243 +RUN;
1244 +%mend MotifRap;
1245 +%MotifRap;
MLOGIC(MOTIFRAP): Début de l'exécution.
MLOGIC(MOTIFRAP) : %GLOBAL ANNEE FIRSTWDAY FIRSTWORKINGDAY DEBUT
MLOGIC(MOTIFRAP) : %LET (le nom de la variable est SYSYEAR)
SYMBOLGEN: La macro-variable SYSDATE est résolue en 05JAN18
SYMBOLGEN: La macro-variable MOTIFRAPPORT est résolue en FINANCIER
MLOGIC(MOTIFRAP) : La condition %IF &MotifRapport EQ FINANCIER est TRUE
MLOGIC(MOTIFRAP) : %LET (le nom de la variable est ANNEE)
SYMBOLGEN: La macro-variable SYSYEAR est résolue en 2018
MLOGIC(MOTIFRAP) : %LET (le nom de la variable est FIRSTWDAY)
SYMBOLGEN: La macro-variable ANNEE est résolue en 2018
MLOGIC(MOTIFRAP) : %LET (le nom de la variable est FIRSTWORKINGDAY)
SYMBOLGEN: La macro-variable FIRSTWDAY est résolue en 21185
WARNING: Argument 2 to function INPUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.
NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set to a missing value.
MLOGIC(MOTIFRAP) : %LET (le nom de la variable est DEBUT)
SYMBOLGEN: La macro-variable FIRSTWORKINGDAY est résolue en .
MPRINT(MOTIFRAP): RUN;
MLOGIC(MOTIFRAP) : Fin de l'exécution.
1246 +%put &Annee;
SYMBOLGEN: La macro-variable ANNEE est résolue en 2018
2018
1247 +%put &FirstWDay;

 

Any idea how to solve this issue.  It is like the SAS on the robot does not recognize 

 

%let FirstWorkingDay=%sysfunc(inputn(&FirstWDay, z8.), date9.);

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

One possibility, although I can't tell you why it would work in some cases but not others ...

 

There is no such thing as a z8 informat.  The "z" family is a set of formats, not informats.  Try switching to this informat instead:

 

8.

 

 

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, can't even look much at that.  I got to %sysfunc(year("&sysdate"d)); and wonder what on earth you are doing.  You seem to understand that %sysfunc() can call functions, and still these are put ino macro variables?  Surely that is just duplicating the data, i.e. you have a perfectly good function, and also the result of function.  The year also returns a number, but you then put it into a text variable (macro is always text), and then duplicate that information in Annee.  You would make your life so much easier using Base SAS to do data manipulations, and call functions when needed rather than storing duplicates of duplicates.

data _null_;
call symput('debut',put(nwkdom(1,2,1,year(today())),date9.));
run;

%put &debut.;

 

Astounding
PROC Star

One possibility, although I can't tell you why it would work in some cases but not others ...

 

There is no such thing as a z8 informat.  The "z" family is a set of formats, not informats.  Try switching to this informat instead:

 

8.

 

 

alepage
Barite | Level 11

Hello, 

 

As you have suggested, I have use the following code and it works!

Thanks a lot for your help.

 

%let sysyear= %sysfunc(year("&sysdate"d));
%let Annee=&sysyear;
%let FirstWDay=%sysfunc(NWKDOM(1,2,1,&Annee));
%let FirstWorkingDay=%sysfunc(inputn(&FirstWDay, 8.), date9.);
%let Debut=%sysfunc(compress(%bquote('&FirstWorkingDay'd)));
%put &sysyear;
%put &annee;
%put &firstwday;
%put &firstworkingday;

ballardw
Super User

Any idea how to solve this issue.  It is like the SAS on the robot does not recognize 

 What robot?

 

If the purpose of this code is to generate values used by a SAS program often it is more stable to either generate the date values such as 20810 (numeric) instead of '01JAN2017'd as having quotes in the macro values often leads to ugly quote around dealing with quotes. Or if you have a need to see 01Jan2017 then have that as the macro variable and when you need to use the SAS date value then "&datemacrovar"d

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1242 views
  • 1 like
  • 4 in conversation