The SAS Output Delivery System and reporting techniques

Google Analytics - Passing Column as variable

Reply
New Contributor
Posts: 4

Google Analytics - Passing Column as variable

Hello All,

I am working on adding google analytics to track reporting usage. Based on the way our .html pages that surface our reports are built, this is how it needs to be created.

I need to dynamically pass the 'file' column within call define as a variable so we know which report was viewed . I am having trouble getting the column name to act as a variable and resolve correctly. Any ideas?

Running on 9.2 32bit

options nocenter ;

DATA testing;

   INPUT filename $ filetype $ file $;

   DATALINES;

  abc_rpt html hello

  xyz_rpt pdf test

;

ods listing close;

ods html file="C:\Testing_links.html"

style=sasweb

;

title;

footnote;

options nodate nonumber;

proc report data=Testing nowd missing split='/'

style(report)={just=center}

;

column filename filetype file ;

define filename  / order "Report Name" style=[just=left width=4in];

define filetype  / display order=data "Format" style=[just=left width=.5in];

define file /noprint;

compute filetype;

if strip(filename) ne '' then do;

urlstring=strip(filename);

%let string = file;

CALL DEFINE(_COL_, 'URL', strip(urlstring) || ' "target="_blank' || %unquote(%nrbquote('" onClick="javascript: pageTracker._trackPageview(''/home/&string'' );')));

end;

endcomp;

run;

ods html close;

ods listing;

The issue is &string is not being resolved correctly.

Once the code below is ran, view the source of the html page.

Towards the bottom you will see the lines below. The setup of quotes double quotes is very important.

<td class="l Data" style=" width: 0.5in;"><a href="abc_rpt "target="_blank" onClick="javascript: pageTracker._trackPageview('/home/file' );">html</a>

<td class="l Data" style=" width: 0.5in;"><a href="xyz_rpt "target="_blank" onClick="javascript: pageTracker._trackPageview('/home/file' );">pdf</a>

The correct output would look like:

<td class="l Data" style=" width: 0.5in;"><a href="abc_rpt "target="_blank" onClick="javascript: pageTracker._trackPageview('/home/hello' );">html</a>

<td class="l Data" style=" width: 0.5in;"><a href="xyz_rpt "target="_blank" onClick="javascript: pageTracker._trackPageview('/home/test' );">pdf</a>

The setup of quotes double quotes is very important.  It needs to resolve exactly as above.

Any help is appreciated! Thanks!

Ask a Question
Discussion stats
  • 0 replies
  • 328 views
  • 0 likes
  • 1 in conversation