I have a table name output_check which have a variable call dps_checks.
in the output log, how can I reference that dps_checks so that this piece of code works :
thank you.
What is the value of &output_name? Please tell us, we can't help you if we don't know what it is.
If there are errors in the log, show us the ENTIRE log for this data step. Copy the log as text and paste it into the window that appears when you click on the </> icon. Saying something isn't working, without showing us the log doesn't help.
From now on, please copy your code as text (not a screen capture) and paste it into the window that appears when you click on the "little running man" icon.
Thanks Paige. please see the text file
Repeating: please copy your code as text (not a screen capture) and paste it into the window that appears when you click on the "little running man" icon.
And I did ask to know what this macro variable value is, I don't see that anywhere.
real time : 0.054
cpu time : 0.046
MPRINT (DPS EXPIN REFORMAT):data AQ OUT.OUTPUT_LOG;
MPRINT (DPS EXPIN REFORMAT):set AQ OUT. OUTPUT LOG
SYMBOLGEN: Macro variable dps checks ok resolved to 1
MPRINT (DPS EXPIN REFORMAT): DPS checks ok= 1;
SYMBOLGEN: Macro variable output name resolved to DPS_KEL_TEST SYMBOLGEN: Macro variable DPS checks ok resolved to 1
MPRINT (DPS EXPIN REFORMAT) : if clientname = DPS KEL TEST and 1 = 1 Then do;
MPRINT (DPS EXPIN REFORMAT) : output file check="PASS";
MPRINT (DPS EXPIN REFORMAT) : multipin vol check = "PASS";
MPRINT (DPS EXPIN REFORMAT) : multipin error= "PASS";
MPRINT (DPS EXPIN REFORMAT): end;
MPRINT (DPS EXPIN REFORMAT): else do;
MPRINT (DPS EXPIN REFORMAT) output file check="FAIL";: MPRINT (DPS EXPIN REFORMAT): multipin vol check = "PASS";
MPRINT (DPS EXPIN REFORMAT): multipin error= "PASS";
MPRINT (DPS EXPIN REFORMAT) : end;
MPRINT (DPS EXPIN REFORMAT):run;
NOTE: 13 observations were read from "AQ OUT,OUTPUT LOG"
NOTE: Data_set "AQ_OUT.OUTPUT_LOG" has 13 observation (s) and 17 variable (3) NOTE: Specifying compression for data set "AQ_OUT-OUTPUT_LOG" has not changed pages
NOTE: The data step took :
real time
0.052
size of 3
When you use a macro variable like &output_name in your code, when you run the code SAS replaces the macro variable with its value. Now this is the important part: when this replacement happens, the result MUST BE valid legal working SAS code.
So your code looks like this:
if clientname = DPS KEL TEST and 1 = 1 Then do;
and this is not valid legal working SAS code. Can you see why this is not valid legal working SAS code?
The advice we ALWAYS give people is to first create WORKING SAS CODE that does what you want without macros and without macro variables. If you can't get it to work without macros and without macro variables, then it will NEVER work with macros and with macro variables. Some people ignore this advice. @Coding4you do not ignore this advice.
Show please show us code that works for one instance without macros and without macro variables.
By the way, it seems as if you have modified the LOG because the way it appears, there should be many errors, but you show no errors whatsoever. Please do not do this.
Yes I noticed that.
the question is how do I reference that in another data step? Because the dps_checks value is one in the output check table. I want to use that so that if it’s 1 then do this if that make sense?
@Coding4you wrote:
Yes I noticed that.
the question is how do I reference that in another data step? Because the dps_checks value is one in the output check table. I want to use that so that if it’s 1 then do this if that make sense?
I don't really know what you are trying to do here with that macro variable. But as I said, you have to start with WORKING valid legal SAS code that does something useful without macros and without macro variables. Get it to work without macros and without macro variables first.
Also, why does your code consistently look like it has typographical errors?
data AQ OUT OUTPUT_LOG:
set AQ OUT. OUTPUT LOG:
That's not a semi-colon on the end, and you can't have spaces in libnames or data set names. Plus other typographical errors. What is causing this?
Dps check is the variable name in the output check table and it will only have two values 0 or 1.
the select into will only return the values. I think it maybe easier to merge it, because I’m trying to perform if &dps_check = 1 then do in another data step which end up 1=1 and it wouldn’t work
@Coding4you wrote:
Dps check is the variable name in the output check table and it will only have two values 0 or 1.
the select into will only return the values. I think it maybe easier to merge it, because I’m trying to perform if &dps_check = 1 then do in another data step which end up 1=1 and it wouldn’t work
If the value of the macro variable DPS_CHECK is 1 then using (&DPS_CHECK=1) in the source code should result in using (1=1) in the generated code. That is what the macro processor does.
If DPS_CHECK is the name of a VARIABLE then you need to use DPS_CHECK in the code not &DPS_CHECK.
Perhaps you should be replacing the 1 in your equality test with value of a macro variable? (DPS_CHECK = &DPS_CHECK) would result in either (DPS_CHECK=1) or (DPS_CHECK=0) based on the value of the macro variable DPS_CHECK.
NOTE: The underscore key seems broken on your keyboard. You keep posting things like Dps check as the name of a variable or a macro variable. Names can only contain one word. No spaces.
data AQ OUT OUTPUT_LOG:
set AQ OUT. OUTPUT LOG:
if clientname = &output name and &DPS checks ok = 1
then do: output file check="PASS";
multipin vol check = "PASS";
multipin error= "PASS";
end;
else do:
output file check="FAIL";
multipin vol check = "PASS";
multipin error= "PASS;
end;
To create that macro variable I used Proc sql; select dps_checks_ok into : dps_checks okay from output_check; quit;
@Coding4you wrote:
data AQ OUT OUTPUT_LOG: set AQ OUT. OUTPUT LOG: if clientname = &output name and &DPS checks ok = 1 then do: output file check="PASS"; multipin vol check = "PASS"; multipin error= "PASS"; end; else do: output file check="FAIL"; multipin vol check = "PASS"; multipin error= "PASS; end; To create that macro variable I used Proc sql; select dps_checks_ok into : dps_checks okay from output_check; quit;
Show us the actual LOG from running that Proc SQL. I expect it to generate errors starting at the variable (or whatever it is supposed to be in your thinking) at the word OKAY.
When code is submitted SAS writes messages in the LOG about the code and results, including syntax problems. It is plain text. You should be able to go to the LOG window, copy text. Then on this forum open a text box by clicking on the </> icon above the message window. Then Paste the text from the log.
You still show code with syntax errors: spaces between an apparent library named OUT and a data set named OUTPUT. That code is also going to expect two data sets in the WORK library named AQ and LOG.
The word NAME following &output is an error. Checks after &DPS is an error. The : at Then Do: is an error.
The Output statement requires the name of a data set on the DATA statement, File is not such, neither is check=pass.
The word Vol after multipin is an error. Check="Pass" is an error;
The attempted assignment of "PASS" to the variable named Error after multipin is an error.
In fact not a single line of your data step does not contain at least one error and that is before even seeing any likely value for the tw0 macro variables Output and DPS.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.