DATA Step, Macro, Functions and more

#BYVAL doesn't work in footnote statement?

Accepted Solution Solved
Reply
PROC Star
Posts: 1,322
Accepted Solution

#BYVAL doesn't work in footnote statement?

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? 


Accepted Solutions
Solution
‎06-14-2017 09:28 AM
SAS Super FREQ
Posts: 708

Re: #BYVAL doesn't work in footnote statement?

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


All Replies
Super User
Posts: 5,511

Re: #BYVAL doesn't work in footnote statement?

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.

Solution
‎06-14-2017 09:28 AM
SAS Super FREQ
Posts: 708

Re: #BYVAL doesn't work in footnote statement?

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.

PROC Star
Posts: 1,322

Re: #BYVAL doesn't work in footnote statement?

[ Edited ]
Posted in reply to Bruno_SAS

Thanks @Bruno_SAS.  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.

 

PROC Star
Posts: 7,474

Re: #BYVAL doesn't work in footnote statement?

@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

 

PROC Star
Posts: 1,322

Re: #BYVAL doesn't work in footnote statement?

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

SAS Super FREQ
Posts: 708

Re: #BYVAL doesn't work in footnote statement?

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/

PROC Star
Posts: 1,322

Re: #BYVAL doesn't work in footnote statement?

Posted in reply to Bruno_SAS

Thanks again @Bruno_SAS.  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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 220 views
  • 1 like
  • 4 in conversation