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

Dear SAS users,

 

I wrote the following:

%let Jahr = 2021 ; * Hier das Jahr einsetzten ;

%put &Jahr.;

%if &Jahr = 2021 %then %do;

%let Quelldatei="GESAMT_WTL_RKR"; %end.;

%else %do;

%let Quelldatei="GESAMT_JHR_RKR_&Jahr.";

%end;

 

and gets :

26 %let Jahr = 2021 ; * Hier das Jahr einsetzten ;

27 %put &Jahr.;

2021

28

29 %if &Jahr. = 2021 %then %do;

30 %let Quelldatei="GESAMT_WTL_RKR"; %end.;

30 %let Quelldatei="GESAMT_WTL_RKR"; %end.;

_

180

ERROR 180-322: Statement is not valid or it is used out of proper order.

WARNING: Apparent invocation of macro END not resolved.

ERROR: The %ELSE statement is not valid in open code.

31 %else %do;

32 %let Quelldatei="GESAMT_JHR_RKR_&Jahr.";

33 %end;

 

how can I correct this?

regards

1 ACCEPTED SOLUTION

Accepted Solutions
utrocketeng
Quartz | Level 8

looks like you have a period (.) at the end of your %end:

%let Quelldatei="GESAMT_WTL_RKR"; %end.;

View solution in original post

3 REPLIES 3
utrocketeng
Quartz | Level 8

looks like you have a period (.) at the end of your %end:

%let Quelldatei="GESAMT_WTL_RKR"; %end.;

PaigeMiller
Diamond | Level 26

Adding:

 

Rarely is it necessary to put macro variable values in quotes. Instead of 

%let Quelldatei="GESAMT_WTL_RKR";

you'd probably be better off using

%let Quelldatei=GESAMT_WTL_RKR;
--
Paige Miller
PierreYvesILY
Pyrite | Level 9
Thank you Paige.
I wish you a happy and successfull year 2021.
Thank you for your help in 2020,
Regards