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

Datasets i and j have the labels and the data as follows.

filename i temp;

proc http url="http://faculty.tuck.dartmouth.edu/images/uploads/faculty/
rafael-laporta/Law_Fin.xls" out=i;
run;

proc import file=i dbms=xls replace out=i;
	sheet="definitions";
	getnames=no;
run;

proc import file=i dbms=xls replace out=j;
	sheet="data";
run;

The labels contain commas, percent signs, and unclosed parentheses as follows. How can I label the data correctly? The following macro incorrectly scans the macro strings due to empty spaces.

210307.png

%macro i;

proc sql noprint;
	select a,d into :i separated by "\",:j separated by "\" from i;
quit;

data j;
	set j;
	%do k=4 %to %sysfunc(countw(&i,\));
		label %scan(&i,&k,\)="%scan(%nrbquote(&j),&k,\)";
	%end;
run;

%mend;

%i

Thanks for help.

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

1. Try using %superq(j)

2. use proc datasets add add labels, do not copy the whole table.

View solution in original post

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

1. Try using %superq(j)

2. use proc datasets add add labels, do not copy the whole table.

ChrisNZ
Tourmaline | Level 20

Also, it'd be a lot simpler to use call execute for this kind of endeavour.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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 lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 1324 views
  • 0 likes
  • 2 in conversation