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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
MikeZdeb
Rhodochrosite | Level 12

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

3 REPLIES 3
MikeZdeb
Rhodochrosite | Level 12

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

AnnieL
Calcite | Level 5

Worked perfectly! Thank you so much! Smiley Happy

SteveNZ
Obsidian | Level 7

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 ;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Update

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1699 views
  • 1 like
  • 3 in conversation