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 ;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.