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 ;

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!

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.

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