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

Hi,

It is possible to use a format as value for a url= style option?

 

Example 1 - Same URL for all the values

 

ods pdf file='eg1.pdf';

proc report data=class spanrows; 
    column sex--weight;
    define sex / order style(column)=[url = 'https://sas.com'];
    define height--weight  / display;
run;

ods pdf close;

 

Example 2 - Using a format (doesn't work)

 

proc format;
    value $ url 'M'='https://sas.com'
                'F'='https://communities.sas.com/';
run;

ods pdf file='eg2.pdf';

proc report data=class spanrows; 
    column sex--weight;
    define sex / order style(column)=[url = $url.];
    define height--weight  / display;

run;

ods pdf close;

Example 3 - Using call define (workaround)

 

ods pdf file='eg3.pdf';

proc report data=class spanrows; 
    column sex--weight;
    define sex / order;
    define height--weight  / display;
    
    compute sex;
        if sex='M' then call define (_COL_,'url','https://sas.com');
        else call define (_COL_,'url','https://communities.sas.com/');
    endcomp;
run;

ods pdf close;

Regards,

1 ACCEPTED SOLUTION

Accepted Solutions
xxformat_com
Barite | Level 11

Hi,

 

Thanks Cynthia, testing again with your program helped me realize that the code I sent missed a format.

The $URL applies to the formatted value of sex, not the unformatted value as I was expecting.

Here is an example:

 

proc format;
    value $ sex 'M'='Male'
                'F'='Female';
    *value $ url 'M'='https://sas.com'
                'F'='https://communities.sas.com/'; *it does not work;
                
    value $ url 'Male'='https://sas.com'
                'Female'='https://communities.sas.com/'; *it works;

run;

ods pdf file='eg2.pdf';

proc report data=class spanrows; 
    column sex--weight;
    define sex / order format=$sex. style(column)=[url = $url.];
    define height--weight  / display;

run;

ods pdf close;

 

View solution in original post

5 REPLIES 5
Cynthia_sas
SAS Super FREQ

Hi:

  The format approach should work. It worked for me using SASHELP.CLASS:

proc format;
    value $url 'M'='https://www.sas.com'
               'F'='https://www.google.com';
run;

ods pdf(id=1) file="c:\temp\url_examp.pdf";
ods html(id=2) path='c:\temp' (url=none) file='url_examp.html';
ods rtf(id=3) file="c:\temp\url_examp.rtf";

proc report data=sashelp.class spanrows; 
    title 'URL example with format';
    column sex age name height weight;
    define sex / order style(column)=[url=$url.];
run;

ods pdf(id=1) close;
ods html(id=2) close;
ods rtf(id=3) close;

The CALL DEFINE example, but I prefer using it for making dynamic URLs:

ods pdf(id=1) file="c:\temp\url_dyn.pdf";
ods html(id=2) path='c:\temp' (url=none) file='url_dyn.html';
ods rtf(id=3) file="c:\temp\url_dyn.rtf";

proc report data=sashelp.class(obs=5) spanrows; 
    title 'URL example with call define';
    column sex age name height weight;
    define sex / order;
	compute name;
	    urlstr = catt('https://www.google.com/search?q=books+',name);
        call define(_col_,'url',urlstr);
	endcomp;
run;

ods pdf(id=1) close;
ods html(id=2) close;
ods rtf(id=3) close;

Cynthia

xxformat_com
Barite | Level 11

Hi,

 

Thanks Cynthia, testing again with your program helped me realize that the code I sent missed a format.

The $URL applies to the formatted value of sex, not the unformatted value as I was expecting.

Here is an example:

 

proc format;
    value $ sex 'M'='Male'
                'F'='Female';
    *value $ url 'M'='https://sas.com'
                'F'='https://communities.sas.com/'; *it does not work;
                
    value $ url 'Male'='https://sas.com'
                'Female'='https://communities.sas.com/'; *it works;

run;

ods pdf file='eg2.pdf';

proc report data=class spanrows; 
    column sex--weight;
    define sex / order format=$sex. style(column)=[url = $url.];
    define height--weight  / display;

run;

ods pdf close;

 

sbxkoenk
SAS Super FREQ

Hello,

Can you show the LOG because for me it works fine? 

I haven't used PDF as output destination though but that cannot be the reason of your problem.

Koen

xxformat_com
Barite | Level 11

There is no issue in the log. There is just no link created in the PDF file.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 942 views
  • 0 likes
  • 4 in conversation