Knowing this will be helpful in other ocasion.
I could refine my question in the following way:
If I have a string like "max(temp(1), temp(2));" stored in a variable cat_str, is it possible to use this in a function.
instead of writing explicitely max_value=max(temp(1), temp(2)); I am looking for using cat_str within the line like max_value=resolve or whatever (cat_str)
@acordes wrote:
Knowing this will be helpful in other ocasion.
I could refine my question in the following way:
If I have a string like "max(temp(1), temp(2));" stored in a variable cat_str, is it possible to use this in a function.
instead of writing explicitely max_value=max(temp(1), temp(2)); I am looking for using cat_str within the line like max_value=resolve or whatever (cat_str)
No. You can use the content of a variable to generate SAS code. You can do it with CALL EXECUTE() or just using PUT statement to write to a file. But that code will run AFTER the current data step finishes.
You can use RESOLVE() to retrieve the results of macro code execution. But the macro code will not have access to the data that the data step is using.
@acordes wrote:
Tom, that's clear now.
But have a look at @Ksharp 's post.
https://communities.sas.com/t5/SAS-Programming/resolving-a-formula-in-a-dataset/m-p/68123
Isn't this what I'm looking for?
If you read that thread it is saying the same thing as I am saying. Either use the string data to generate code to run later. Or jump through hoops to push that data into text that can be passed to the %sysevalf() macro function via the resolve() function. In the marked answer the convert the string var into the character string that represents the value of var before pushing it to the macro processor to be evaluated.
Congratulation! Tom.
Thank you for your help with SAS code.
I learn a lot from your post.
HHC
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.