BookmarkSubscribeRSS Feed
owenwqp1
Obsidian | Level 7

 I applied the code provided in this topic to convert character variable to numeric, it works quite well for individual data sets.But when I apply the code in macro, I meet problems. When I use "proc sql" to find out character variables in data sets, SAS tells me that there are no character variables in the data sets but actually there are some. I don't know why, so could you kindly help me out? 

 

%macro sic2_state(i,j);
	
	data &j&i;
		set &j&i;
	run;
	proc sql;
	create table char_cur&j&i as 
		select name from dictionary.columns where libname='WORK' and MEMNAME="&j&i" and type='char'; 
quit;
%mend;
%sic2_state(1999,Connecticut)
%sic2_state(1999,Florida)
%sic2_state(1999,Indiana)
%sic2_state(1999,Tennessee)

 

Thanks a lot! Cheers, Owen

2 REPLIES 2
Astounding
PROC Star

Within dictionary.columns, all the MEMNAME values are stored in uppercase.  So the initial hurdle to overcome is to change the MEMNAME criterion to:

 

and memname = upcase("&j&i")

owenwqp1
Obsidian | Level 7
@Astounding Thank you so much Astounding! That's the point! Regards, Owen

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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