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

I'm using #BYVAL in a footnote statement in 9.4M3.  Looks like the footnote is reporting the value of the next by-group rather than the current by group.  It works as expected in the title statement.

 

proc sort data=sashelp.class out=class;
  by sex;
run;

options nobyline;

proc report data=class nowd;
  by sex;
  title1 "below is print out of: #BYVAL1";
  footnote1 "above is print out of: #BYVAL1";;
run;

byvalue.PNG

 

 

Looks like same issue as:

https://communities.sas.com/t5/SAS-GRAPH-and-ODS-Graphics/SG-ODS-RTF-BODYTITLE-BYVAL-in-FOOTNOTE-sta...

 

I tried in 9.3 and get the same result. 

 

Does this mean that #BYVAL doesn't work well for footnotes? 

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

According to the documentation, the #BYVAL, #BYVAR etc. are only available for the TITLE statement, but not in the FOOTNOTE statement.

 

See here

TITLE, http://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=p10gcmrmf83iaxn1ilrx4pra969n.htm&docs...

FOOTNOTE, http://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=n0wh407rnaleinn1rqyudxuzhkhu.htm&docs...

 

So works as documented.

 

One can argue, that one should get some sort of warning when using the #BY... in a FOOTNOTE statement.

View solution in original post

7 REPLIES 7
Astounding
PROC Star

Just to add to the merriment, when I test your program (Unix/Linux), I'm getting a footnote that includes the characters "#BYVAL1" without the value of the variable.

BrunoMueller
SAS Super FREQ

According to the documentation, the #BYVAL, #BYVAR etc. are only available for the TITLE statement, but not in the FOOTNOTE statement.

 

See here

TITLE, http://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=p10gcmrmf83iaxn1ilrx4pra969n.htm&docs...

FOOTNOTE, http://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=n0wh407rnaleinn1rqyudxuzhkhu.htm&docs...

 

So works as documented.

 

One can argue, that one should get some sort of warning when using the #BY... in a FOOTNOTE statement.

Quentin
Super User

Thanks @BrunoMueller.  That's an unfortunate surprise.  I hadn't before thought about possible differences between TITLE statements and FOOTNOTE statements.

 

It interesting that in SAS/GRAPH, titles and footnotes are documented together http://support.sas.com/documentation/cdl/en/graphref/69717/HTML/default/viewer.htm#n19y35ila5aaysn1q..., and from the related thread https://communities.sas.com/t5/SAS-GRAPH-and-ODS-Graphics/SG-ODS-RTF-BODYTITLE-BYVAL-in-FOOTNOTE-sta... it looks like using #BYVAL in  a SAS/GRAPH or SG plot footnote works, as long as you use GFOOTNOTE so that footnote is part of the graph.  Maybe I'll put in a idea submisssion to get #BYVAL working in SAS BASE footnotes.

 

I haven't used #BYVAL much.  But seems like often when I try, I end up backing away from it and resort to writing my own macro  looping.  Beause I ended up wanting to use that #BYVAL to somewhere like a footnote or a table of contents link, or a file name, or .... so &BYVAL becomes more flexible.  But if I were still in the role of making statistical reports for internal users that didn't have to be pretty, I'm sure I would use #BYVAL more often.

 

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
art297
Opal | Level 21

@Quentin: If you don't mind deleting two pages, the following will produce the desired result:

proc sort data=sashelp.class out=class;
  by sex;
run;

data class;
  set class;
  by sex;
  x=0;
  if last.sex then do;
    output;
    x=1;
    output;
  end;
  else output;
run;

options nobyline;

proc report data=class nowd;
  by sex x;
  title1 "below is print out of: #BYVAL1";
  footnote1 "above is print out of: #BYVAL1";
run;

Art, CEO, AnalystFinder.com

 

Quentin
Super User

Thanks @art297, but in my setting of storted process making web reports, it isn't feasible to delete the extra pages.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
BrunoMueller
SAS Super FREQ

If you need this information in the footnote statement, then I suggest you have a look at programming pattern described by @ChrisHemedinger, see his blog entries

 

http://blogs.sas.com/content/sasdummy/2012/03/20/sas-program-by-processing/

and

http://blogs.sas.com/content/sasdummy/2012/03/23/improving-on-a-sas-programming-pattern/

Quentin
Super User

Thanks again @BrunoMueller.  Yes, that's the sort of macro looping I generally use.  But I thought for this project I might be in a setting where I could use the BY statement and benefit from the efficiency, so wanted to give it a shot.  For now, I just moved by footnote to a subtitle to get it working.  I'm sure by the end it will be refactored into macro looping like Chris showed.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.

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
  • 7 replies
  • 2434 views
  • 1 like
  • 4 in conversation