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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
snoopy369
Barite | Level 11

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

3 REPLIES 3
snoopy369
Barite | Level 11

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;

 

snoopy369
Barite | Level 11

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;

 

Jay_TxOAG
Quartz | Level 8

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 1149 views
  • 0 likes
  • 2 in conversation