Help using Base SAS procedures

Using SAS to generate HTML code

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Using SAS to generate HTML code

Hi everyone! I'm a fairly new user to SAS and have recently run into a problem.

I'm working on a project that requires that I generate a list of URLs while pulling from a variable on the dataset. Each URL is the same except for one value that gets pulled off of the dataset.

ex: http://www.census.gov/cgi-bin/sssd/naics/naicsrch?code="xxx"&search=2007

xxx = the variable I want to pull off of the dataset

I've been using the following code:

. . .

  ELSE IF FIRST.xxx AND zzz = 1 THEN PUT '<br /><i>NOTE: ALL OF <a href=""http://www.census.gov/cgi-bin/sssd/naics/naicsrch?code=' xxx '&search=2007"'">' xxx'</a> IS IN ' yyy '</i>';

. . .

But for some reason, there's an extra space between variable "xxx" and the rest of the link. I end up getting:

http://www.census.gov/cgi-bin/sssd/naics/naicsrch?code=xxx%20&search=2007

Has anyone tried this before and know what's going on? I would greatly appreciate any help at all!

Thank you!


Accepted Solutions
Solution
‎06-06-2012 03:05 PM
Valued Guide
Posts: 765

Re: Using SAS to generate HTML code

hi ... in the PUT portion, add a backspace ... +(-1) ...

PUT '<br /><i>NOTE: ALL OF <a href=""http://www.census.gov/cgi-bin/sssd/naics/naicsrch?code='   xxx  +(-1)   '&search=2007"'">'  xxx  +(-1) '</a> IS IN ' yyy '</i>';


example ...

data _null_;

xxx = '12345';

put 'this is a test' xxx 'with no backspace';

put 'this is a test' xxx +(-1) 'with a backspace';

run;


the LOG ...


this is a test12345 with no backspace

this is a test12345with a backspace

View solution in original post


All Replies
Solution
‎06-06-2012 03:05 PM
Valued Guide
Posts: 765

Re: Using SAS to generate HTML code

hi ... in the PUT portion, add a backspace ... +(-1) ...

PUT '<br /><i>NOTE: ALL OF <a href=""http://www.census.gov/cgi-bin/sssd/naics/naicsrch?code='   xxx  +(-1)   '&search=2007"'">'  xxx  +(-1) '</a> IS IN ' yyy '</i>';


example ...

data _null_;

xxx = '12345';

put 'this is a test' xxx 'with no backspace';

put 'this is a test' xxx +(-1) 'with a backspace';

run;


the LOG ...


this is a test12345 with no backspace

this is a test12345with a backspace

New Contributor
Posts: 2

Re: Using SAS to generate HTML code

Worked perfectly! Thank you so much! Smiley Happy

Frequent Contributor
Posts: 87

Re: Using SAS to generate HTML code

Another option:

data test ;

xxx = '12345' ;

    url = cats('<br /><i>NOTE: ALL OF <a href="http://www.census.gov/cgi-bin/sssd/naics/naicsrch?code=',xxx,'&search=2007">',xxx,'</a> IS IN yyy </i>') ;

run ;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 306 views
  • 1 like
  • 3 in conversation