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

Hi all,

In ods html very easy hide link under some short label:

data input;

    length pgmfield $500;

    name="name1";

    pgmfield= '<a href=http://translate.google.com/>'||name||'</a>';

    output;

    name="name2";

    pgmfield= '<a href=http://google.com/>'||name||'</a>';

    output;

    name="name3";

    pgmfield= '<a href=\\C:\...\test.docx>'||name||'</a>';

    output;

run;

proc report data = input;

column  name pgmfield;

define name/   noprint;

define pgmfield/' link_text';

run;

I need make the same in pdf, so in pdf document create link also possible:

data input;

    length lnk pgmfield $500;

    name="name1";

    path="http://translate.google.com";

    output;

    name="name2";

    path="\\C...\test.docx>";

    output;

    name="name3";

    path="http://translate.google.com/";

    output;

run;

ods pdf file='...test.pdf';

proc report data = input;

column   name path ;

define name/   noprint;

define lnk/' lnk ';

compute path;

        Call Define(_col_,'Url',path);

endcomp;

run;

ods pdf close;

But how to hide full url(or path to some file) under short name(label) as it was in first example(ods html)?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi,

I guess I'm not entirely sure what it is that you are trying to do. However, the program below shows how to assign a URL to a cell based on the value of another cell using PROC REPORT. I don't see, in your example, what the value of the LNK variable is; I only see the value being assigned to the PATH variable. In fact, I see that you have LNK on the report, but do not see that you ever assign LNK a value or have it in the COLUMN statement, which should be generating an error message, so I'm not sure that your code, as posted will work. I would expect you to see a warning message similar to this:

WARNING: LNK is not in the report definition.

NOTE: Variable LNK is uninitialized.

  Here's the program. I'm not sure you need a data step to create the INPUT dataset or the PATH variable. You could do it several different ways, but the program only shows 2 of them.

cynthia

   
ods listing close;
*** Method 1: Use Call DEFINE;
ods pdf file='c:\temp\test_url1.pdf';
    
proc report data = sashelp.class(obs=3) nowd;
title '1) Click on the AGE column to follow the link';
column   name sex age height weight ;
define sex / 'Gender';
compute age;
   if sex = 'F' then
      Call Define(_col_,'Url','http://maps.google.com');
   else if sex = 'M' then
      Call Define(_col_,'Url','http://support.sas.com/resources/papers/proceedings11/246-2011.pdf');
endcomp;
run;
    
ods pdf close;


** Method 2: Use a format;

proc format;

  value $lnk 'Maps'='http://maps.google.com'

             'Paper' = 'http://support.sas.com/resources/papers/proceedings11/246-2011.pdf'

  ;

run;


ods pdf file='c:\temp\test_url2.pdf';
    
proc report data = sashelp.class(obs=3) nowd;
title '2) Click on the LINK column to follow the link';
column   name sex age LINK ;
define sex / 'Gender';
define LINK / COMPUTED
       style(column)={url=$lnk.};
compute link / character length=5;
   if sex = 'F' then
      link = 'Maps';
   else if sex = 'M' then
      link = 'Paper';
endcomp;
run;
   
ods pdf close;

View solution in original post

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

Hi,

I guess I'm not entirely sure what it is that you are trying to do. However, the program below shows how to assign a URL to a cell based on the value of another cell using PROC REPORT. I don't see, in your example, what the value of the LNK variable is; I only see the value being assigned to the PATH variable. In fact, I see that you have LNK on the report, but do not see that you ever assign LNK a value or have it in the COLUMN statement, which should be generating an error message, so I'm not sure that your code, as posted will work. I would expect you to see a warning message similar to this:

WARNING: LNK is not in the report definition.

NOTE: Variable LNK is uninitialized.

  Here's the program. I'm not sure you need a data step to create the INPUT dataset or the PATH variable. You could do it several different ways, but the program only shows 2 of them.

cynthia

   
ods listing close;
*** Method 1: Use Call DEFINE;
ods pdf file='c:\temp\test_url1.pdf';
    
proc report data = sashelp.class(obs=3) nowd;
title '1) Click on the AGE column to follow the link';
column   name sex age height weight ;
define sex / 'Gender';
compute age;
   if sex = 'F' then
      Call Define(_col_,'Url','http://maps.google.com');
   else if sex = 'M' then
      Call Define(_col_,'Url','http://support.sas.com/resources/papers/proceedings11/246-2011.pdf');
endcomp;
run;
    
ods pdf close;


** Method 2: Use a format;

proc format;

  value $lnk 'Maps'='http://maps.google.com'

             'Paper' = 'http://support.sas.com/resources/papers/proceedings11/246-2011.pdf'

  ;

run;


ods pdf file='c:\temp\test_url2.pdf';
    
proc report data = sashelp.class(obs=3) nowd;
title '2) Click on the LINK column to follow the link';
column   name sex age LINK ;
define sex / 'Gender';
define LINK / COMPUTED
       style(column)={url=$lnk.};
compute link / character length=5;
   if sex = 'F' then
      link = 'Maps';
   else if sex = 'M' then
      link = 'Paper';
endcomp;
run;
   
ods pdf close;

Yura2301
Quartz | Level 8

Hi Cynthia,

Regarding small issue in examples in my code-yes, you are right, LNK should be replaced to Path etc., I just accidentally put wrote column names when typed second example.

And your example is exactly what I need:)

Thanks!

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