Resolution of multiple ampersands using macro variables

This code works in SAS EG for local (hidden sensitive information):

*---- two values: DEV (ALIASDEV) and PROD (ALIASPROD);
%let my_environment = ALIASDEV;
%let ALIASPROD= (hidden_tns_prod);
%let ALIASDEV= (hidden_tns_dev);

libname mylib oracle user=username password='my_password' path="&&my_environment";

But this code is not (with rsubmit;)

rsubmit;
*---- two values: DEV (ALIASDEV) and PROD (ALIASPROD);
%let my_environment = ALIASDEV;
%let ALIASPROD= (hidden_tns_prod);
%let ALIASDEV= (hidden_tns_dev);

libname mylib oracle user=username password='my_password' path="&&my_environment";
endrsubmit;

here is the error message:

ERROR: connection error ORACLE: ORA-12154: TNS: could not resolve the specified connection identifier. ERROR: error in LIBNAME statement.

What I'm trying to do is have a macro (my_environment) which I can easily switch between my dev and prod databases.

thank

+4
source share
2 answers

, , , . , , .

:

  • , , . IE, &val_sept &val_oct, &&val_&mon %let mon=sept.
  • , . , &sept &oct, &&&mon. &sept %let mon=sept.

- ; SAS , .

:

  • 1 .
  • , , , .

:

%let x=a;
%let a=b;
%let b=c;

%put &&x;

1: &&x โ†’ (&&)(x) โ†’ (&)(x) โ†’ &x 2: &x โ†’ a

%put &&&x;

1: &&&x โ†’ (&&)(&x) โ†’ (&)(a) โ†’ &a 2: &a โ†’ b

%put &&&&x;

1: &&&&x โ†’ (&&)(&&) (x) โ†’ (&)(&)(x) โ†’ &&x 2: &&x โ†’ (&&)(x) โ†’ (&)(x) โ†’ &x 2: &x โ†’ a

%put &&&&&x;

1: &&&&&x โ†’ (&&)(&&)(&x) โ†’ (&)(&)(a) โ†’ &&a 2: &&a โ†’ (&&)(a) โ†’ (&a) 3: &a โ†’ b

%put &&&&&&x;

1: &&&&&&x โ†’ (&&)(&&)(&&) (x) โ†’ (&)(&)(&)(x) โ†’ &&&x 2: &&&a โ†’ (&&)(&x) โ†’ (&a) 3: &a โ†’ b

, .

. sas MACRO ampersand.

+4

, "(hidden_tns_dev)" "ALIASDEV", : path = "& && my_environment".

+2

All Articles