DATA Step, Macro, Functions and more

%SYSCALL POKELONG. Memory allocation during SAS macro runtime.

Reply
Occasional Contributor
Posts: 14

%SYSCALL POKELONG. Memory allocation during SAS macro runtime.

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:

  1. Paper 1510-2014 Direct Memory Data Management Using the APP Tools
  2. SUGI 29 Paper 264-29 A-P-P Advanced Data Management Functions

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 need to "migrate" this to pure SAS macro. The first problem which I don't how to resolve is how to allocate memory - receive a pointer where I can write to. Does anyone have any ideas?
 
 
Thanks and kind regards,
Igor
Super User
Super User
Posts: 9,840

Re: %SYSCALL POKELONG. Memory allocation during SAS macro runtime.

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.

Super Contributor
Posts: 320

Re: %SYSCALL POKELONG. Memory allocation during SAS macro runtime.

I think you need to explain more of what you're doing. You're not going to be able to use the macro language in %SYSFUNC etc. to just write directly to random memory.

Can you post a short, runnable example of a function that you'd like to turn into pure macro language, and why you want to do so?
Occasional Contributor
Posts: 14

Re: %SYSCALL POKELONG. Memory allocation during SAS macro runtime.

The code is in the question, I need to do the same using SAS macro: allocate memory, write to it, read it.
Respected Advisor
Posts: 4,797

Re: %SYSCALL POKELONG. Memory allocation during SAS macro runtime.

[ Edited ]

@sspkmnd

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. 

Occasional Contributor
Posts: 14

Re: %SYSCALL POKELONG. Memory allocation during SAS macro runtime.

Completely agree with you that question is kinda weird. But I am interested if this actually possible.
Super User
Super User
Posts: 8,279

Re: %SYSCALL POKELONG. Memory allocation during SAS macro runtime.

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?

 

Occasional Contributor
Posts: 14

Re: %SYSCALL POKELONG. Memory allocation during SAS macro runtime.

[ Edited ]

I expected this answer Smiley Happy 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.

Ask a Question
Discussion stats
  • 7 replies
  • 192 views
  • 0 likes
  • 5 in conversation