BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
FK1
Lapis Lazuli | Level 10 FK1
Lapis Lazuli | Level 10

Hello Everybody,

 

I came upon a very curious problem:

I have a code in which I use name literals:

 

data "dataset mit leerzeichen"n;
set sashelp.class;
"variable mit leerzeichen"n = 1;
run;

Now, when I run the above code in a interactive EG-Session, it works perfectly fine, i.e. no errors or warnings.

 

However, when I run the exact same code in Batch-Mode, I get the following ERROR MESSAGE:

 

ERROR: The name variable mit leerzeichen is not a valid SAS name.

 

  1. Obviously, there must exist some differences in BATCH vs. INTERACTIVE EG-SESSION mode. Related to the above issue, what is the difference?
  2. Is there a system option, that forces SAS BATCH-MODE to work exactly as in INTERACTIVE EG-SESSION mode?

Thanks in advance for any helpful pointing into the direction of solving this issue.

 

FK

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisBrooks
Ammonite | Level 13

You can use Proc Optsave for that i.e.

 

proc optsave out=opts;
run;

View solution in original post

5 REPLIES 5
ChrisBrooks
Ammonite | Level 13

Try putting the following two options statements at the start of your code

 

options validmemname=extend;
options validvarname=any;

data "dataset mit leerzeichen"n;
set sashelp.class;
"variable mit leerzeichen"n = 1;
run;

I can only assume you're using different autoexecs when running in batch and interactive with one containing the options and one not.

FK1
Lapis Lazuli | Level 10 FK1
Lapis Lazuli | Level 10

Hello Mr. Brooks,

 

thank you for your advice. It worked!

I do have a follow-up question, however:

 

Do you know how to output the system options into a SAS data set? I only get them into the LOG, when executing this code:

 

PROC OPTIONS;
RUN;

As a workaround one could of course divert the log with PROC PRINTTO:

 

filename divlog "/pathname/logdiverted.txt";

PROC PRINTTO LOG=divlog;
run;

PROC OPTIONS   ;
RUN;

However, I end up having a file on which I then would have to further work on.

ChrisBrooks
Ammonite | Level 13

You can use Proc Optsave for that i.e.

 

proc optsave out=opts;
run;
ballardw
Super User

@ChrisBrooks wrote:

You can use Proc Optsave for that i.e.

 

proc optsave out=opts;
run;

and reload the options with

Proc optload data=opts;

run;

 

if you need to make option settings temporarily and then restore them (as often as needed).

FK1
Lapis Lazuli | Level 10 FK1
Lapis Lazuli | Level 10

Thanks everybody for your help! Glad to see, there are so many SAS Specialists 🙂

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 5 replies
  • 1546 views
  • 3 likes
  • 3 in conversation