BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Hedegaard
Calcite | Level 5

Hello,

I have a problem with a macro variable that SAS changes upon compilation, when I have positioned it inside an rsubmit statement.

Specifically, if I run the following code

rsubmit;

%let longStringInSas=70044562 70038118 70000987 70006274 70006876 70009855 70010417 70010502 70010846 70013132 70013741 70017303 70017365 70018846 70018970 70019083 70019999 70020810 70023702 70024663 70027142 70027281 70027650 70029126 70032494 70035989 70037073 70044862 70050145;

endrsubmit;

then I get the following in the log (which carries over as a mistake to what I'm trying to do):

10123  rsubmit;

NOTE: Remote submit to SASHOST commencing.

13384  %let longStringInSas=70044562 70038118 70000987 70006274 70006876 70009855 70010417 70010502 70010846 70013132 70013741 70017303 70017365 70018846 70018970 70019083 70019999 70020810 70023702 70024663 70027142 70027281

13384!  70027650 70029126 70032494 70035989

13385  7003707370044862 70050145;

NOTE: Remote submit to SASHOST complete.

Notice how the second to last and third to last numbers are concatenated.

If I submit the %let statement without including the rsubmit-statements, then the log seems fine:

10124  %let longStringInSas=70044562 70038118 70000987 70006274 70006876 70009855 70010417 70010502 70010846 70013132 70013741 70017303 70017365 70018846 70018970 70019083 70019999 70020810 70023702 70024663 70027142 70027281

10124!  70027650 70029126 70032494 70035989 70037073 70044862 70050145;

How come does this work differently depending on whether I use rsubmit or not? And any ideas as to how to make it work within rsubmit?

Kind regards,

Hedegaard.

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

It worked for me both inside and outside of an rsubmit block with your string (Win7 64bit, SAS 9.2 TS Level 2M3). What SAS version and OS are you using (for both the "local" and remote session?).

What you see is a log message. Are you also having missing blanks if you %put the macro variable to the log?

You can always create the macro variable locally and then push it to the remote session using %syslput.

Or you could pass the string in several steps, something like

%let longStringInSas=70044562 70038118 70000987 70006274 70006876 70009855;
%let longStringInSas=&longStringInSas 70010417 70010502 70010846 70013132 70013741;
%let longStringInSas=&longStringInSas 70017303 70017365 70018846 70018970 70019083;
%let longStringInSas=&longStringInSas 70019999 70020810 70023702 70024663 70027142;
%let longStringInSas=&longStringInSas 70027281 70027650 70029126 70032494 70035989;
%let longStringInSas=&longStringInSas 70037073 70044862 70050145;

The only thing I can think of creating the problem is some CR/LF issue where you have a mix of a Windows and a UNIX/Linux environment.

View solution in original post

10 REPLIES 10
Patrick
Opal | Level 21

It worked for me both inside and outside of an rsubmit block with your string (Win7 64bit, SAS 9.2 TS Level 2M3). What SAS version and OS are you using (for both the "local" and remote session?).

What you see is a log message. Are you also having missing blanks if you %put the macro variable to the log?

You can always create the macro variable locally and then push it to the remote session using %syslput.

Or you could pass the string in several steps, something like

%let longStringInSas=70044562 70038118 70000987 70006274 70006876 70009855;
%let longStringInSas=&longStringInSas 70010417 70010502 70010846 70013132 70013741;
%let longStringInSas=&longStringInSas 70017303 70017365 70018846 70018970 70019083;
%let longStringInSas=&longStringInSas 70019999 70020810 70023702 70024663 70027142;
%let longStringInSas=&longStringInSas 70027281 70027650 70029126 70032494 70035989;
%let longStringInSas=&longStringInSas 70037073 70044862 70050145;

The only thing I can think of creating the problem is some CR/LF issue where you have a mix of a Windows and a UNIX/Linux environment.

Hedegaard
Calcite | Level 5

Hello, Patrick.

Thanks.

The local SAS version is 9.1 and local OS is Win XP.

The version of SAS on the server is 9.2 - I have been told it's a Windows server.

If I %put the macro variable to the log, it still appears in the wrong way (with two of the numbers being concatenated). At first, I had used your suggestion of defining the string in several steps, which worked, but was unpretty.

Creating the macro variable locally and pushing it to the server with %syslput seems to work much better. Using that method, I have no visible problems.

Hedegaard
Calcite | Level 5

I have a peculiar problem now. When I run my program (which is way too big and involved for me to post here), it outputs among other things all but the third to last number in the macro variable. I have tried permuting the order of the numbers, and it is consistently the third to last number, which is being ignored.

I suspect that this has something to do with the variable being too long. It does this regardless of whether I use the %syslput method or the method of passing the string in several steps. Evidence for it to have something to do with the length of the string is that if I let the string contain only six numbers, then all six numbers are contained in the output.

ballardw
Super User

If it is doing something odd based on position I would look for any loop or position counters getting accidentally incremented, especially if it isn't affecting the last two values.

Patrick
Opal | Level 21

Just out of curiousity: If you %bqoute() the string passed to the macro var does the issue remain.

A macro var should be able to store 32K. %length(&macrovar) will tell you how long the stored string currently is.

Suggest that you post this issue in a new thread so people look at it again (as this thread here is already flagged as answered). Possibly also contact SAS TechSupport.

FriedEgg
SAS Employee

Patrick,

32K is the default value for MVARSIZE, a option that controls the maximum size (in kilobytes) for storing a macro variable.  This is not however a limitation to the length of the data stored inside a macro variable, which is 65534 as of at least 9.1

Tom makes a very valid proposition.  Often rsubmit inside of macro exhibit unexpected behavior due to the nature of how sas compiles.

Syslput and sysrput are the recommended methods for transfering macro variable between sessions initiated by rsubmits.

Tom
Super User Tom
Super User

Are you doing this inside a macro?

I know that there are problems with macro generated rsubmit code where SAS appears to be tokenizing the strings wrong.

I have had it bite me where it caused trouble and just changing the number of characters inside a comment made the code work.

Hedegaard
Calcite | Level 5

Hi, all.

Thanks for the answers.

Patrick: I tried using the %bquote function, but the same problem remains. In fact, now it ignores the second to last number in the list as opposed to the third to last, like it did before. This appears to have something to do with which number is in position 256 of the string. So in

%let longStringInSas=%bquote(70044562 70038118 70000987 70006274 70006876 70009855 70010417 70010502 70010846 70013132 70013741 70017303 70017365 70018846 70018970 70019083 70019999 70020810 70023702 70024663 70027142 70027281 70027650 70029126 70032494 70035989 70037073 70044862 70050145);

the second to last number now contains the 256th position in the string, while it was the third to last one before.

Tom and FriedEgg: I am not doing this inside a macro function. The structure of the program around this assignment is:

%aMacroFunction;

%let longStringInSas=%bquote(70044562 70038118 70000987 70006274 70006876 70009855 70010417 70010502 70010846 70013132 70013741 70017303 70017365 70018846 70018970 70019083 70019999 70020810 70023702 70024663 70027142 70027281 70027650 70029126 70032494 70035989 70037073 70044862 70050145);

%syslput longStringInSas = &longStringInSas;

rsubmit;

%anotherMacroFunction;

[lots of macro variable assignments]

endrsubmit;

Tom
Super User Tom
Super User

You should probably try to create the simpliest version of your program that exhibits the issue and send it SAS technical support.

Another way to move information between SAS/Connect sessions is with datasets instead of macro variables.

data longstr;

  longstr="&longstr";

run;

rsubmit;

   proc upload data=longstr out=longstr status=n; run;

   data _null_;

      set longstr;

      call symputx('longstr',longstr);

   run;

FriedEgg
SAS Employee

Give the following a try in your enviornment as a test.

1. Create a macro to use inside local and remote sessions (plcnt)

2. Create a macro variable (longstring) of space delimited numerics with length 9

3. Validate execution of macro in rsubmit and preservation of data in longstring

filename acm temp;

%let acm=%sysfunc(pathname(acm));

data _null_;

input;

file acm;

put _infile_;

cards4;

%macro plcnt(str);

  %put Length= %length(&str) Words=%sysfunc(countw(&str));

%mend;

;;;;

run;


%include "&acm";

%let longstring=%sysfunc(repeat(%str(12345678),%sysfunc(floor(32767/9))));

%plcnt(&longstring)

signon subtask1 sascmd="/usr/local/SAS/SASFoundation/9.2/sas" wait=no;

%syslput longstring2=&longstring /remote=subtask1;

%syslput acm="&acm" /remote=subtask1;

rsubmit subtask1;

%include &acm;

%plcnt(&longstring2)

data _null_;

  array x[%sysfunc(countw(&longstring2))](&longstring2);

  dim=dim(x);

  mean=mean(of x

  • );
  •   put 'Keys: ' dim 'Mean: 'mean;

    run;

    endrsubmit subtask1;

    signon subtask2 sascmd="/usr/local/SAS/SASFoundation/9.2/sas" wait=no;

    %syslput longstring3=&longstring /remote=subtask2;

    %syslput acm="&acm" /remote=subtask2;

    rsubmit subtask2;

    %include &acm;

    %plcnt(&longstring3)

    data _null_;

      array x[%sysfunc(countw(&longstring3))](&longstring3);

      dim=dim(x);

      median=median(of x

  • );
  •   put 'Keys: ' dim 'Median: 'median;

    run;

    endrsubmit subtask2;

    waitfor _all_ subtask1 subtask2;

    %plcnt(&longstring)

    data _null_;

      array x[%sysfunc(countw(&longstring))] (&longstring);

      dim=dim(x);

      mean=mean(of x

  • );
  •   median=median(of x

  • );
  •   put 'Keys: ' dim ' Mean: 'mean ' Median: ' median;

    run;

    signoff subtask1;

    signoff subtask2;


    Log Output for local session:

         Length= 32768 Words= 3641

         Length= 32768 Words= 3641

         Keys: 3641  Mean: 12345678  Median: 12345678

    Log Output for subtask1:

         Length= 32768 Words= 3641

         Keys: 3641 Mean: 12345678

    Log Output for subtask2:

         Length= 32768 Words= 3641

         Keys: 3641 Median: 12345678

    sas-innovate-2024.png

    Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

    Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

     

    Register now!

    How to Concatenate Values

    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.

    Click image to register for webinarClick image to register for webinar

    Classroom Training Available!

    Select SAS Training centers are offering in-person courses. View upcoming courses for:

    View all other training opportunities.

    Discussion stats
    • 10 replies
    • 1521 views
    • 0 likes
    • 5 in conversation