BookmarkSubscribeRSS Feed
thummala
Obsidian | Level 7

Hi,

 

Can you please help me in figuring out the code for below scenario.

 

I have a variable with pagenumbers. I want these numbers to be hyperlinked to an external file. When there are one page numebr in the variable then there are no issues. But when there are multiple page numbers not sure how to code it.

 

pages
14
12, 15
8, 14, 20, 30, 32, 35

 

 

 

 

if index(pages,',')=0 then pg_=strip(pages);
else if index(pages,',') then do;
    pg_=substr(pages, 1, index(pages,','));
    pg1_= substr(pages,index(pages,',')+1);
end;
 
if pages ne '' and index(pages, ',')=0 then origin = '{CRF {\field {\*\fldinst HYPERLINK "\\blankcrf.pdf#page=' ||
trim(left(pg_)) || '"}{\fldrslt {\cs15\cf2 Page ' || trim(left(pg_)) || '}}}}';
else if pages ne '' and countc(pages, ',')=1 then origin = '{CRF {\field {\*\fldinst HYPERLINK "\\blankcrf.pdf#page=' ||
trim(left(pg_)) || '"}{\fldrslt {\cs15\cf2 Pages ' || trim(left(pg_)) || '}}}}' ||'{{\field {\*\fldinst HYPERLINK "\\blankcrf.pdf#page=' ||
trim(left(pg1_)) || '"}{\fldrslt {\cs15\cf2 ' || trim(left(pg1_)) || '}}}}';
 
else if pages ne '' and countc(pages, ',') gt 1 then origin='{Multiple CRF {\field {\*\fldinst HYPERLINK "\\blankcrf.pdf#page=1"}{\fldrslt {\cs15\cf2 Pages}}}}';

 

Can anyone help me in looping it n number of times based on the page numbers so that all the pages can be hyperlinked and I can replace the "Multiple CRF" value when there are more than two pages in the pages variable.

 

 

Thank You for your time.

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

I would advise you simplfy your question as I really don't want to start looking through RTF code and such like.  If you want to loop over those values, then use a do loop (and maybe an array if necessary) e.g;

data want;
  do i="14","12, 15","8, 14, 20, 30, 32, 35";
    ...do something here e.g...
    page="Some page number="||strip(i);
  end;
run;

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!

Discussion stats
  • 1 reply
  • 930 views
  • 0 likes
  • 2 in conversation