Hello community,
I am desperately trying to set up an IF/ELSE where the if-condition is based on a string comparison. If the variable is not equal to PRODET (I also tried 'PRODET') I want the macro to be executed. This is what looked pretty reasonable to me, but we tried various options.
DATA _NULL_;
IF (&v_modul_akt. NE PRODET)
THEN CALL EXECUTE ('%set_module_view');
RUN;
I would even go 1 step further and do:
DATA _NULL_;
IF symget("v_modul_akt") NE "PRODET")
THEN CALL EXECUTE ('%set_module_view');
RUN;
to ensure that "strange" value of v_modul_akt won't blow up my sas 🙂
Text without quotes around it is interpreted as code. So in your program, both the text resolved from &v_module_akt. an the word PRODET are both interpreted as variable names:
DATA _NULL_;
IF (&v_modul_akt. NE PRODET)
THEN CALL EXECUTE ('%set_module_view');
RUN;
Sinc nothing in the program assigns a value to those variables, they are both missing, so the values are equal. In your log you should see a NOTE indicating that the variables are uninitialized.
Try this instead:
DATA _NULL_;
IF ("&v_modul_akt." NE "PRODET")
THEN CALL EXECUTE ('%set_module_view');
RUN;
And may the SAS be with you!
I would even go 1 step further and do:
DATA _NULL_;
IF symget("v_modul_akt") NE "PRODET")
THEN CALL EXECUTE ('%set_module_view');
RUN;
to ensure that "strange" value of v_modul_akt won't blow up my sas 🙂
Thanks for the help!
Unfortunately, I still struggle:
%LET v_modul_akt = PRODET;
DATA _NULL_;
IF (symget("&v_modul_akt.") NE "PRODET")
THEN CALL EXECUTE ('%set_module_view');
RUN;
This snippet still calls the macro, even though the if-statement says "PRODET" NE "PRODET"
Read the code I typed...
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: