Hey guys,
This is my first post, just let me know if you need me to elaborate.
I've created a proc freq table that I've outputted to a work file, and it looks like the below:
Status | COUNT | PERCENT |
Successful | 200 | 0.769231 |
Unsuccessful | 50 | 0.192308 |
Unknown | 10 | 0.038462 |
I want to get the PERCENT value where the status was "Successful" and assign it to a macro variable that I can use at a later part of the programme.
Does anyone know how I can do this? Thank you in advance for you help.
I also asked on StackOverflow and a solution was provider there:
You can create a macro variable using CALL SYMPUTX() function.
%let percent=;
data _null_;
set have;
if status='Successfull" then call symputx('percent',percent');
run;
If you want to test whether the string in that macro variable is larger than some other floating point value make sure to use %SYSEVALF() as the normal %EVAL() macro function used in %IF will only handle integer arithmetic.
%if %sysevalf(&percent > 0.5 ) %then %do;
....
%end;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.