BookmarkSubscribeRSS Feed
Escada
Obsidian | Level 7

Hi,

 

I have a very large table which I would like to query on a regular basis, based on several parameters that I predefine. For example, I can identify:

Table: T1

Column 10

Row 05

Which then retrieves me the data for a specific cell following the parameters (coordinates) identified, making use of the code below:

 

PROC SQL;
CREATE TABLE QUERY_OUTPUT AS
SELECT
t1.VALUE_DECIMAL,
t1.TABLE_ID,
t1.X,
t1.Y
FROM LARGE_TABLE t1
WHERE t1.TABLE_ID ='T1' AND t1.X ='10' AND t1.Y ='05';
QUIT;

 

However I would like to replace those parameters (in bold) by an excel table(s)/vectors, which can be imported into a SAS dataset(s) and be used as parameters for the query.

 

Something like:

 

Table_ID     X      Y   

     T1         10     05

     T2         15     10

     ...           ...      ...    

 

Can somebody help me finding a solution for this?

 

Thank you.

 

Fernando

 

 

3 REPLIES 3
LinusH
Tourmaline | Level 20
To use a parameter table consider encapsulate your SQL in a macro.
Then call the macro by a call execute in a data step that reads your parameter table.
Data never sleeps
Escada
Obsidian | Level 7

Hi Linus,

 

Can you elaborate a litle bit more on that?

Do you have an example of code that can guide me a litle bit?

 

thanks!

LinusH
Tourmaline | Level 20
There are tons of examples both on these communities and if you care to search SAS documentation.
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 25. 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
  • 3 replies
  • 1149 views
  • 0 likes
  • 2 in conversation