BookmarkSubscribeRSS Feed
arpitsharma27
Calcite | Level 5

Team,

I have this dataset:

    data have1;
    input name $23.;
    datalines;
    &temp.alpha
    &temp.beta
    ;
    run;

This is what I want:

%let temp=var1;
proc sql;
	create table want1 as
		select upcase(resolve(name)) as new_var
			from have1
				where upcase(resolve(name))=upcase("var1alpha")
	;
quit;

I am able to get what I want using resolve().

 

But with this, I have to make change in all the existing code.

I am reaching out to you to find , if any, alternative solution.

 

I tried having the following dataset but it does NOT work.

data have2;
input name $23.;
datalines;
resolve(&temp.alpha)
resolve(&temp.beta)
;
run;

Any alternative you would suggest?

 

Thanks

 

5 REPLIES 5
arpitsharma27
Calcite | Level 5

Sir,

With all due respect, it has been clearly laid out. 
You will have to run the code and read my comments in there.

 

Kurt_Bremser
Super User

I only see a dataset with one variable and one observation. Since this is no good on its own, I was asking for the bigger picture. But maybe you don't have one.

 

To suggest an alternative (as you wanted in your first post), we need to know what you're aiming at.

SAS will not resolve anything (no macro references, no function call, nothing) in a datalines block. And your SQL approach works, as demonstrated. But we have no idea why it would cause such a big change to existing code, as we don't see anything of that.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

An example of what you have, what you want, and an explanation of the process would help.  Its unlikely that this is the best approach.

gamotte
Rhodochrosite | Level 12

Hello,

 

You can resolve the macrovariables in a data step prior to the proc sql :

 

data have2;
    set have1;
    name=resolve(name);
run;

proc sql;
	create table want1 as
	select upcase(name) as new_var
	from have2
	where upcase(name)=upcase("var1alpha")
	;
quit;


 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 5 replies
  • 2019 views
  • 0 likes
  • 4 in conversation