BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
wellsfargo123
Fluorite | Level 6

 

 

Given below is a macro to return a link in a macro variable appr_link. I am getting some errors. The log is also attached.

 

%let Report_Name=testng;

%put &=Report_Name.;

%let dev_email ="emailid ";

 

 

%macro test_m(dev_email=, repname=, appr_link=);

data _null_;

     length str_date $10.;

     call symput('str_date',put(today(),MMDDYY10.));

run;

%put &=str_date;

 

%LET Appr_Body_Text = As the report owner, I have reviewed the schedule/data for the &repname. and believe it accurately reflects the loan activity for this population of accounts/process. I am not aware of any material issues related to accuracy or completeness related to this process.;

%let aprlink="<pre> <a href='mailto:emailid?subject=BUSINESS APPROVAL: &Report_Name.; sent on &str_date. %nrstr(&cc=) %sysfunc(dequote(&dev_email.)) %nrstr(&body=)&Appr_Body_Text.'>REPORT APPROVAL EMAIL</a></pre>" ;

%put &=str_date;

%put &=aprlink.;

%let appr_link=&aprlink.;

 

&aprlink.;

 

%mend;

%test_m(dev_email=&dev_email. ,repname=&Report_Name.,appr_link=aprlink)

%put &appr_link.;

 

    **********************************LOG**********************************************************

27        

28         %let Report_Name=testng;

29         %put &=Report_Name.;

SYMBOLGEN:  Macro variable REPORT_NAME resolves to testng

REPORT_NAME=testng

30         %let dev_email ="emailid ";

31        

32        

33         %macro test_m(dev_email=, repname=, appr_link=);

34         data _null_;

35              length str_date $10.;

36              call symput('str_date',put(today(),MMDDYY10.));

37         run;

38         %put &=str_date;

39        

40         %LET Appr_Body_Text = As the report owner, I have reviewed the schedule/data for the &repname. and believe it accurately

40       ! reflects the loan activity for this population of accounts/process. I am not aware of any material issues related to

40       ! accuracy or completeness related to this process.;

41         %let aprlink="<pre> <a href='mailto:Emailid?subject=BUSINESS APPROVAL: &Report_Name.; sent on

41       ! &str_date. %nrstr(&cc=) %sysfunc(dequote(&dev_email.)) %nrstr(&body=)&Appr_Body_Text.'>REPORT APPROVAL EMAIL</a></pre>" ;

42         %put &=str_date;

43         %put &=aprlink.;

44         %let appr_link=&aprlink.;

45        

46         &aprlink.;

47        

48         %mend;

49         %test_m(dev_email=&dev_email. ,repname=&Report_Name.,appr_link=aprlink)

 

 

 

 

MLOGIC(TEST_M):  Beginning execution.

SYMBOLGEN:  Macro variable DEV_EMAIL resolves to "emailid"

SYMBOLGEN:  Macro variable REPORT_NAME resolves to testng

MLOGIC(TEST_M):  Parameter DEV_EMAIL has value "emailid”

MLOGIC(TEST_M):  Parameter REPNAME has value testng

MLOGIC(TEST_M):  Parameter APPR_LINK has value aprlink

MPRINT(TEST_M):   data _null_;

MPRINT(TEST_M):   length str_date $10.;

MPRINT(TEST_M):   call symput('str_date',put(today(),MMDDYY10.));

MPRINT(TEST_M):   run;

 

NOTE: Variable str_date is uninitialized.

NOTE: DATA statement used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

     

 

3                                                          The SAS System                           14:58 Tuesday, December 12, 2023

 

MLOGIC(TEST_M):  %PUT &=str_date

SYMBOLGEN:  Macro variable STR_DATE resolves to 12/12/2023

STR_DATE=12/12/2023

MLOGIC(TEST_M):  %LET (variable name is APPR_BODY_TEXT)

SYMBOLGEN:  Macro variable REPNAME resolves to testng

MLOGIC(TEST_M):  %LET (variable name is APRLINK)

SYMBOLGEN:  Macro variable REPORT_NAME resolves to testng

SYMBOLGEN:  Macro variable STR_DATE resolves to 12/12/2023

SYMBOLGEN:  Macro variable DEV_EMAIL resolves to "emailid”

SYMBOLGEN:  Macro variable APPR_BODY_TEXT resolves to As the report owner, I have reviewed the schedule/data for the testng and

            believe it accurately reflects the loan activity for this population of accounts/process. I am not aware of any

            material issues related to accuracy or completeness related to this process.

NOTE: The quoted string currently being processed has become more than 262 characters long.  You might have unbalanced quotation

      marks.

MLOGIC(TEST_M):  %PUT &=str_date

SYMBOLGEN:  Macro variable STR_DATE resolves to 12/12/2023

STR_DATE=12/12/2023

MLOGIC(TEST_M):  %PUT &=aprlink.

SYMBOLGEN:  Macro variable APRLINK resolves to "<pre> <a href='mailto:Emailid?subject=BUSINESS APPROVAL:

            testng; sent on 12/12/2023 &cc= emailid&body=As the report owner, I have reviewed the

            schedule/data for the testng and believe it accurately reflects the loan activity for this population of

            accounts/process. I am not aware of any material issues related to accuracy or completeness related to this

            process.'>REPORT APPROVAL EMAIL</a></pre>"

SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.

NOTE: The quoted string currently being processed has become more than 262 characters long.  You might have unbalanced quotation

      marks.

APRLINK="<pre> <a href='mailto:Emailid?subject=BUSINESS APPROVAL: testng; sent on 12/12/2023 &cc=

Emailid &body=As the report owner, I have reviewed the schedule/data for the testng and believe it

accurately reflects the loan activity for this population of accounts/process. I am not aware of any material issues related to

accuracy or completeness related to this process.'>REPORT APPROVAL EMAIL</a></pre>"

MLOGIC(TEST_M):  %LET (variable name is APPR_LINK)

SYMBOLGEN:  Macro variable APRLINK resolves to "<pre> <a href='mailto:Emailid?subject=BUSINESS APPROVAL:

            testng; sent on 12/12/2023 &cc= Emailid &body=As the report owner, I have reviewed the

            schedule/data for the testng and believe it accurately reflects the loan activity for this population of

            accounts/process. I am not aware of any material issues related to accuracy or completeness related to this

            process.'>REPORT APPROVAL EMAIL</a></pre>"

SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.

NOTE: The quoted string currently being processed has become more than 262 characters long.  You might have unbalanced quotation

      marks.

SYMBOLGEN:  Macro variable APRLINK resolves to "<pre> <a href='mailto:Emailid?subject=BUSINESS APPROVAL:

            testng; sent on 12/12/2023 &cc= Emailid &body=As the report owner, I have reviewed the

            schedule/data for the testng and believe it accurately reflects the loan activity for this population of

            accounts/process. I am not aware of any material issues related to accuracy or completeness related to this

            process.'>REPORT APPROVAL EMAIL</a></pre>"

SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.

NOTE: The quoted string currently being processed has become more than 262 characters long.  You might have unbalanced quotation

      marks.

MPRINT(TEST_M):   "<pre> <a href='mailto:Emailid?subject=BUSINESS APPROVAL: testng; sent on 12/12/2023

&cc= Emailid &body=As the report owner, I have reviewed the schedule/data for the testng and believe it

accurately reflects the loan activity for this population of accounts/process. I am not aware of any material issues related to

accuracy or completeness related to this process.'>REPORT APPROVAL EMAIL</a></pre>";

 

MLOGIC(TEST_M):  Ending execution.

WARNING: Apparent symbolic reference APPR_LINK not resolved.

NOTE: Line generated by the macro variable "APRLINK".

49           "<pre> <a href='mailto:Emailid?subject=BUSINESS APPROVAL: testng; sent on 12/12/2023 &cc=

             ___________________________________________________________________________________________________________________

             180

4                                                          The SAS System                           14:58 Tuesday, December 12, 2023

 

49       ! emailid &body=As the report owner, I have reviewed the schedule/data for the testng and believe

49       ! it accurately

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

50         %put &appr_link.;

&appr_link.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Based on how you are calling it it looks like want to pass in the NAME of macro variable to create.

You should check whether or not that macro variable exists.  If it does not exist you will need to define it as GLOBAL so it will live after the macro finishes.

 

It kind of looks like you want to generate a string like this one:

<a href="mailto:emailid?subject='BUSINESS APPROVAL: REPORT NAME HERE (sent on 12/12/2023)'
 &cc='you@company.com'
 &body='As the report owner, I have reviewed the schedule/data for
 the REPORT NAME HERE and believe it accurately reflects the loan activity
 for this population of accounts/process. I am not aware of any material issues
 related to accuracy or completeness related to this process.'"
>REPORT APPROVAL EMAIL
</a>

So use a macro like this one:

%macro test_m(dev_email,repname,appr_link);
%if not %symexist(&appr_link) %then %global &appr_link;
%local today;
%let today=%sysfunc(date(),mmddyy10.);

%let &appr_link=
<a href="mailto:emailid?subject='BUSINESS APPROVAL: &repname. (sent on &today)'
 %str(&)cc=&dev_email. 
 %str(&)body='As the report owner, I have reviewed the schedule/data for
 the &repname. and believe it accurately reflects the loan activity for
 this population of accounts/process. I am not aware of any material issues
 related to accuracy or completeness related to this process.
'">REPORT APPROVAL EMAIL</a>
;
%mend test_m;

And call it like this:

%test_m
(dev_email='you@company.com'
,repname=REPORT NAME HERE
,appr_link=myvar
);

Then you can check the value that was stored into the macro variable like this:

%put &=myvar;

PS: Display dates in MDY or DMY order will confuse half of your audience.

 

 

View solution in original post

7 REPLIES 7
Tom
Super User Tom
Super User

So exactly what is it that you are trying to do?

 

If looks like you are trying to generate some HTML?  So show us exactly what HTML text you want to generate.

 

And why are you trying to put this HTML text into a macro variable?  What do you plan to do with the macro variable once you have it?

 

Note that it is a LOT (a LOT a LOT) easier to work with text in a dataset then in macro variables.

wellsfargo123
Fluorite | Level 6

I am trying to create a macro which will return an html link with the values passed to macro. I am passing two parameters, developer email and reportname and want to return the link in appr_link.  Also  adds today's date to the link. This macro intended to used by the team to create links as required

.

data _null_;
%let str_date=%sysfunc(today(),mmddyy10.);
run;
%put &=str_date.;

%LET Appr_Body_Text = As the report owner, I have reviewed the schedule/data for the Report : &repname. and believe it accurately reflects the loan activity for this population of accounts/process. I am not aware of any material issues related to accuracy or completeness related to this process.;
%put &=Appr_Body_Text.;
%let appr_link="<pre> <a href='mailto:mailid?subject=BUSINESS APPROVAL: &Report_Name.; sent on &str_date. %nrstr(&cc=) %sysfunc(dequote(&dev_email.)) %nrstr(&body=)&Appr_Body_Text.'>REPORT APPROVAL EMAIL</a></pre>" ;
%put &=str_date.;

Tom
Super User Tom
Super User

Can you paste an example of a validly generated string?

Remember to use the Insert Code button to paste/edit the text so the forum does not try to reflow it into paragraphs.

Also remember that HTML does NOT care about white space in general.  So put in some line breaks between words or tokens so the string is legible and does to extend beyond the screen.  (65 to 70 character max per line is a good rule of thumb to use).

 

You seem to have more than two inputs mentioned in the code.  Do you have two different names you need to use for the report? Because you are referencing two different macro variables.

 

What are they going to do with this string once they have it?

Are they going to use it to write a FILE?  Perhaps you should just be generating part of data step that generates PUT statements that they can include the middle of the data step they are writing to create the file?

 

 

Tom
Super User Tom
Super User

Based on how you are calling it it looks like want to pass in the NAME of macro variable to create.

You should check whether or not that macro variable exists.  If it does not exist you will need to define it as GLOBAL so it will live after the macro finishes.

 

It kind of looks like you want to generate a string like this one:

<a href="mailto:emailid?subject='BUSINESS APPROVAL: REPORT NAME HERE (sent on 12/12/2023)'
 &cc='you@company.com'
 &body='As the report owner, I have reviewed the schedule/data for
 the REPORT NAME HERE and believe it accurately reflects the loan activity
 for this population of accounts/process. I am not aware of any material issues
 related to accuracy or completeness related to this process.'"
>REPORT APPROVAL EMAIL
</a>

So use a macro like this one:

%macro test_m(dev_email,repname,appr_link);
%if not %symexist(&appr_link) %then %global &appr_link;
%local today;
%let today=%sysfunc(date(),mmddyy10.);

%let &appr_link=
<a href="mailto:emailid?subject='BUSINESS APPROVAL: &repname. (sent on &today)'
 %str(&)cc=&dev_email. 
 %str(&)body='As the report owner, I have reviewed the schedule/data for
 the &repname. and believe it accurately reflects the loan activity for
 this population of accounts/process. I am not aware of any material issues
 related to accuracy or completeness related to this process.
'">REPORT APPROVAL EMAIL</a>
;
%mend test_m;

And call it like this:

%test_m
(dev_email='you@company.com'
,repname=REPORT NAME HERE
,appr_link=myvar
);

Then you can check the value that was stored into the macro variable like this:

%put &=myvar;

PS: Display dates in MDY or DMY order will confuse half of your audience.

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 7 replies
  • 909 views
  • 0 likes
  • 4 in conversation