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!
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
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
Worked perfectly! Thank you so much! ![]()
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 ;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.