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 The 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.
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
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;
Make sure that your terminal emulation uses the correct codepage and keyboard mapping for your mainframe.
@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.
Square brackets are not part of the EBCDIC character set.
Are you sure this can be done @Kurt_Bremser ?
There seem to be methods for square brackets:
http://x3270.bgp.nu/Brackets.html
(and other results of a search for "ebcdic square brackets")
@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?).
Googling with keywords: IBM 3270 square brackets I get results like here.
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"
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
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';
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.
SAS is definitely kicking my behind lol!
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;
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
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')
;
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.