The SAS Output Delivery System and reporting techniques

Getting the ACROSS variable value in Proc Report

Accepted Solution Solved
Reply
Contributor
Posts: 45
Accepted Solution

Getting the ACROSS variable value in Proc Report

I am interested in using the value of an ACROSS variable in the URL of my Call Define statement in my compute statement.

 

In the example below, I'm wondering if Proc Report gives me a way to access the value of each TYPES variable as the columns are being built, so that I can include it in the URL link? Can I access the value from a compute statement using the N variable?

 

Thanks for the help.

 

 

options missing="";

 

data REPORT;

 input VARIABLE $ TYPES $;

 datalines;

VAR1 TYPE1

VAR1 TYPE2

VAR1 TYPE3

VAR1 TYPE5

;

 

PROC FORMAT ;

 VALUE $TYPE

 'TYPE1'='Type 1'

 'TYPE2'='Type 2'

 'TYPE3'='Type 3'

 'TYPE4'='Type 4'

 'TYPE5'='Type 5';

Run ;

 

proc report data=REPORT nowd;

 column ("Variables" variable) ("TYPES" types,n);

 define variable / '';

 define types / across '' format=$type. preloadfmt;

 define n / '' format=comma12.;

 

 compute types;

  If _c2_>0 then

   call define("_c2_","style","style={url = '<MY URL>' }");

 endcomp;

 run;


Accepted Solutions
Solution
‎02-25-2016 05:42 PM
Super Contributor
Posts: 250

Re: Getting the ACROSS variable value in Proc Report

Alternately, if you're trying to get the "Type 2" etc. into the name, I think you would go this route (using a format, and _COL_ instead of "_C2_").  I don't think there's a way to directly access the across value itself.

 

Since you're presumably constructing these compute blocks individually through use of a macro, I probably would eschew the format and just pass the value of the variable to the macro directly if you can.  If not, then the format may be useful.

 

 

 

PROC FORMAT ;
 VALUE $TYPE
 'TYPE1'='Type 1'
 'TYPE2'='Type 2'
 'TYPE3'='Type 3'
 'TYPE4'='Type 4'
 'TYPE5'='Type 5';
 value NType
 1='Type 1'
 2='Type 2'
 3='Type 3'
 4='Type 4'
 5='Type 5';
Run ;
proc report data=REPORT nowd;
 column ("Variables" variable) ("TYPES" types,n);
 define variable / '';
 define types / across '' format=$type. preloadfmt;
 define n / '' format=comma12.;
 compute types;
  If _c2_>0 then
   call define(_COL_,"style",cats("style={url = '",put(_COL_,NType.),"'" ));
 endcomp;
run;

 

View solution in original post


All Replies
Super Contributor
Posts: 250

Re: Getting the ACROSS variable value in Proc Report

[ Edited ]

Do you mean like this?

proc report data=REPORT nowd;
 column ("Variables" variable) ("TYPES" types,n);
 define variable / '';
 define types / across '' format=$type. preloadfmt;
 define n / '' format=comma12.;
 compute types;
  If _c2_>0 then
   call define("_c2_","style",cats("style={url = '",_C2_,"'" ));
 endcomp;
run;

 

Solution
‎02-25-2016 05:42 PM
Super Contributor
Posts: 250

Re: Getting the ACROSS variable value in Proc Report

Alternately, if you're trying to get the "Type 2" etc. into the name, I think you would go this route (using a format, and _COL_ instead of "_C2_").  I don't think there's a way to directly access the across value itself.

 

Since you're presumably constructing these compute blocks individually through use of a macro, I probably would eschew the format and just pass the value of the variable to the macro directly if you can.  If not, then the format may be useful.

 

 

 

PROC FORMAT ;
 VALUE $TYPE
 'TYPE1'='Type 1'
 'TYPE2'='Type 2'
 'TYPE3'='Type 3'
 'TYPE4'='Type 4'
 'TYPE5'='Type 5';
 value NType
 1='Type 1'
 2='Type 2'
 3='Type 3'
 4='Type 4'
 5='Type 5';
Run ;
proc report data=REPORT nowd;
 column ("Variables" variable) ("TYPES" types,n);
 define variable / '';
 define types / across '' format=$type. preloadfmt;
 define n / '' format=comma12.;
 compute types;
  If _c2_>0 then
   call define(_COL_,"style",cats("style={url = '",put(_COL_,NType.),"'" ));
 endcomp;
run;

 

Contributor
Posts: 45

Re: Getting the ACROSS variable value in Proc Report

No, your other answer is, I think, the closest I can get to a solution. I am now convinced that the across variable's value is not available from Proc Report.

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 451 views
  • 0 likes
  • 2 in conversation