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

Hi,

   I am very new to mainframe SAS so I might not explain this right.  I am given a script that I need to assign a text to a variable.  However, when I hit the brackets from the keyboard ( [ ] ), i am getting a symbol Characters.PNGThe text I want to type in is below:

SUBJECT="[/DOCUMENTS] TEST 123"

 

Essentially, the text above will be inserted in the subject line of an email.  When I run the job, I get an output of below. 

 

 

Capture.PNG

I am not sure what I am missing.  Can someone please let me know if you have seen this before? I searched the internet with no luck.

 

I appreciate the help and thank you all!

Bagar

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

I was just correcting the statements in your last post. If you want to write something you need to use a PUT statement. Just setting a variable will not cause it to be written.
You can either construct a value into a variable and PUT the variable.


Or skip the variable and include the string in the PUT statement. In that case the concatenation operators are not needed.

put 'AD'X '/DOCUMENTS' 'BD'X ' TEST 123';


If you are trying to build part of a statement, like the FILENAME statement then you will probably want to create a macro variable and use that.  So first get the value into a macro variable.

data _null_;
  call symputx('subject','AD'X || '/DOCUMENTS' || 'BD'X ||' TEST 123');
run;

Then in the next step you can use the value in your FILENAME statement.

filename mymail email subject="&subject" ;

If you need to use the left and right brackets a lot it might help to put them into macro variables by themselves.

data _null_;
  call symputx('LB','AD'X);
  call symputx('RB','BD'X);
run;

Then you can use them in other quoted strings. Make sure to use double quote characters so that the macro variable references are resolved.

data _null_;
  filename mymail email 'customer@companyname.com' subject="&lb./DOCUMENTS&rb. TEST 123";
  put "Dear Sir,"
      / "Here is your email message with &lb.square brackets&rb."
      / "SAS"
  ;
run;

View solution in original post

14 REPLIES 14
bagary
Calcite | Level 5
Thank you for responding. Where would I go to check this and how can I confirm it is mapped correctly?
Kurt_Bremser
Super User

@bagary wrote:
Thank you for responding. Where would I go to check this and how can I confirm it is mapped correctly?

This depends on the software used for connecting to the mainframe. Your mainframe admins should be able to help you.

ChrisNZ
Tourmaline | Level 20

Square brackets are not part of the EBCDIC character set.

Are you sure this can be done @Kurt_Bremser ?

ChrisNZ
Tourmaline | Level 20

@Kurt_Bremser  Oh wow. I see. So much fun to be had trying to use these non-standard characters!

 

@bagary Probably best to turn local MF knowledge (as Kurt advised, who am I to say otherwise?).

Patrick
Opal | Level 21

Googling with keywords: IBM 3270 square brackets I get results like here.

bagary
Calcite | Level 5

Thanks Patrick, Kurt and Chris.

I tried the following letters (see below) with the x3270 mode on my keyboard. 

SUBJECT="x'ad'DOCUMENTS¦ TEST123"

SUBJECT="x'BA'DOCUMENTS¦ TEST123"

SUBJECT="&x'BA'DOCUMENTS¦ TEST123"

Capture.PNG

I am able to generate the emails with the following subject line:

X'AD'DOCUMENTS¦ TEST123

X'BA'DOCUMENTS¦ TEST123

&X'BA'DOCUMENTS¦ TEST123

 

Where do I set X'AD' and X'BD' or X'BA' and X'BB' to generate the square brackets, [ ]?  

 

Thanks guys!

bagary

 

Tom
Super User Tom
Super User

First the X goes on the end of the quoted string. Just like all of the other literals (dates, times, datetime, names, etc.).

Second it does not go inside of other quotes.

Did you try:

SUBJECT='ad'x || '/DOCUMENTS' || 'bd'x ||' TEST 123';
bagary
Calcite | Level 5

Thank you Tom!

I tried but now it does not create an email.

SUBJECT='AD'X || '/DOCUMENTS' || 'BD'X ||' TEST 123';

I also tried assigning to a variable and tried both A and &A but with no luck.

LENGTH A VARCHAR(80);         
A='AD'X                   
FILENAME MYMAIL EMAIL     
SUBJECT=A;         

 I also tried but it did not work also 

SUBJECT='AD'X || '/DOCUMENTS'

Now that I am using concatenation, ||, the script does not produce an email anymore.   Smiley SadSmiley FrustratedSmiley Embarassed

SAS is definitely kicking my behind lol!

Tom
Super User Tom
Super User

I was just correcting the statements in your last post. If you want to write something you need to use a PUT statement. Just setting a variable will not cause it to be written.
You can either construct a value into a variable and PUT the variable.


Or skip the variable and include the string in the PUT statement. In that case the concatenation operators are not needed.

put 'AD'X '/DOCUMENTS' 'BD'X ' TEST 123';


If you are trying to build part of a statement, like the FILENAME statement then you will probably want to create a macro variable and use that.  So first get the value into a macro variable.

data _null_;
  call symputx('subject','AD'X || '/DOCUMENTS' || 'BD'X ||' TEST 123');
run;

Then in the next step you can use the value in your FILENAME statement.

filename mymail email subject="&subject" ;

If you need to use the left and right brackets a lot it might help to put them into macro variables by themselves.

data _null_;
  call symputx('LB','AD'X);
  call symputx('RB','BD'X);
run;

Then you can use them in other quoted strings. Make sure to use double quote characters so that the macro variable references are resolved.

data _null_;
  filename mymail email 'customer@companyname.com' subject="&lb./DOCUMENTS&rb. TEST 123";
  put "Dear Sir,"
      / "Here is your email message with &lb.square brackets&rb."
      / "SAS"
  ;
run;
bagary
Calcite | Level 5

Tom, I really do appreciate your help.

 

I looked at your many suggestions on the script.  I took the snippet of the code with your code but it did not create an email (see below).

 

OPTIONS SYMBOLGEN MACROGEN MPRINT;                                                                      
CALL SYMPUTX('LB','AD'X);                                      
CALL SYMPUTX('RB','BD'X);                                              
FILENAME MYMAIL EMAIL                                          
SUBJECT="&LB./DOCUMENTS&RB. TEST 123";                         
    ATTACH=("TST.G5.SP9.Daily"                                
        TYPE='TEXT/TXT' EXT='CSV');                            
DATA _NULL_;                                                   
 FILE MYMAIL    
                                               
 TO=('bagary@email.com');                                
 RUN;                               

 If I remove the 2 lines

CALL SYMPUTX('LB','AD'X);                                      
CALL SYMPUTX('RB','BD'X);

 It will create an email with the subject line..

&LB./DOCUMENTS&RB. TEST 123

Tom
Super User Tom
Super User

Your code does not make any sense. You cannot put a CALL SYMPUTX() statement outside of a data step. No more than you could put any other data step statement outside of a data step.

There is no ATTACH statement.  I suspect that you have inserted an extra semi-colon in the middle of your FILENAME statement.  

Note to avoid this I always place the ending semi-colon for a multiple line statement on a new line, instead of hiding it at the end of the line.

FILENAME MYMAIL EMAIL                                          
  SUBJECT="&LB./DOCUMENTS&RB. TEST 123"
  ATTACH=("TST.G5.SP9.Daily" TYPE='TEXT/TXT' EXT='CSV')
;         
bagary
Calcite | Level 5

Hi Tom! Forgive me as I was not listening to you.  It is now working and below is the code.

  DATA _NULL_;                                                   
     CALL SYMPUTX('LB','AD'X);                                    
     CALL SYMPUTX('RB','BD'X);                                    
   RUN;                                                           
  DATA _NULL_;                                                             
  FILENAME MYMAIL EMAIL                                           
  SUBJECT="&LB./DOCUMENTS&RB. TEST 123"                           
      ATTACH=("TST.123.DAILY"                                 
          TYPE='TEXT/TXT' EXT='CSV');                             
  DATA _NULL_;                                                    
   FILE MYMAIL                                                    
   TO=('bagary@email.com');     
  RUN; 

 

First, I have to make variables in Macro as you stated and use it to assign in the subject line.

 

Tom THANK YOU again!

 

~bagary  

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 14 replies
  • 2650 views
  • 0 likes
  • 5 in conversation