BookmarkSubscribeRSS Feed
Yuriy_pbb
Calcite | Level 5

Hi everyone,

 

I'm using SAS EG 9.4 and currently trying out the proc ds2. What I am trying to do is to use the value from a variable as a table name in the set statement and not specifying the table name explicitly. 

 

proc ds2;
    data differences (overwrite=yes);
    dcl double count_diff;

        method compareTables(char(255) inBaseTable, char(255) inCompareTable);

 

        set {select * from (select * from inBaseTable) as base_data
        except
        select * from (select * from inCompareTable) as compare_data};

end;

 

The table names are passed to the method compareTables, when the codes is being compiled and executed the following error message is being thrown. Apparently the variable contatining the table name is not resolved.

 

Yuriy_pbb_0-1674476501050.png

 

How can I use a variable instead of table name in the sql set statement?

 

Thanks

1 REPLY 1
LinusH
Tourmaline | Level 20

I don't know what you can and cannot do in SET statement for PROC DS2.

But an easy way out is to store the result of your query in a macro variable instead, prior to the PROC DS2 program.

Data never sleeps

SAS Innovate 2025: Call for Content

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 239 views
  • 0 likes
  • 2 in conversation