I need to allocate memory (directly in RAM), then write values to it, and then read them. There are a set of SAS functions usually references as APP: ADDR, PEEK, PEEKC, the CALL POKE routine, and their so-called LONG 64-bit counterparts. There are several papers with many examples on how to do so:
but only in the case of using SAS data step. Allocation memory in this case is just declaring a variable (not really a runtime case, but at least something).
data debug;
length v $200;
pv = addrlong(v);
call pokelong('just a value', pv);
v2 = peekclong(pv);
put 'address: ' pv $hex16.;
put 'value: ' v2;
run;
/*
address: 9FFFFFFFEC0A18B0
value: just a value
*/
I don't see how you can. Macro is not and executable language. It is a text find replace system. It is there to simplify the task of writing text, nothing else.
Personally, I would advise that if you having to use these kind of functions in the first place, there is something wrong with the process, and putting it into macro is only going to exacerbate your problems. There are other ways of working with large numbers.
Why? Is this just an experiment or is this for an actual use case? And if it's for an actual use case then can you please explain what you have and what you're actually trying to achieve? Using pokelong() etc. is something rarely done and needed.
@RW9 wrote it already but here again: SAS Macro language is your "automatic typewriter" allowing you to dynamically generate SAS code which then gets executed. Why does this need to be in a macro?
If you just want to write your own function or call routine then may be have a look into Proc FCMP.
What do you want to poke into memory?
Are you trying to find a way to take advantage of the newly announce MELTDOWN security bug in INTEL processors?
I expected this answer but no. And this can be exploited in SAS data step if actually possible to exploit in SAS, no need in pure SAS macro. I was just interested in possibility of memory management using pure SAS macro.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.