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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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