BookmarkSubscribeRSS Feed
Andres_Fuentes
Calcite | Level 5

Hello, good afternoon, I would like to ask for a little help with something. In the Guide server we have several tables listed by years, I have a process which analyzes the tables but what I want to achieve is that the user selects the year with a prompt and executes the analysis qwerys.

 

These are examples with the names of the tables that I have.

table2018

table2019

table2020

ejemplo.PNG

 

thanks for your time.

 

3 REPLIES 3
Reeza
Super User
Create a custom prompt for year (ie selectedYear) and then use table&selectedYear in your code when you want to reference that table.

I'm assuming that's your question, since there isn't really a clear question in your post.
Andres_Fuentes
Calcite | Level 5

Hi, 

Here is a qwery, text in red I would like it to be variable by year in the FROM. if the person enters 2020 take the table TABLE2020, if the person enters 2019 that take the table TABLE2019

 

PROC SQL;
CREATE TABLE WORK.QUERY_TABLETEST AS
SELECT t1.Ano,
(INPUT(t1.IdComuna,BEST32.)) AS ID_COMUNA
(SUM(t1.Col01 - t1.Col04 - t1.Col05 )) AS TOTAL
FROM TABLE2020  t1
GROUP BY
t1.Ano,
t1.IdComuna;
QUIT;

 

 

maybe I could explain myself better

 

Reeza
Super User
Create a custom prompt for year (ie selectedYear) and then use table&selectedYear in your code when you want to reference that table.

So your code would become:

PROC SQL;
CREATE TABLE WORK.QUERY_TABLETEST AS
SELECT t1.Ano,
(INPUT(t1.IdComuna,BEST32.)) AS ID_COMUNA
(SUM(t1.Col01 - t1.Col04 - t1.Col05 )) AS TOTAL
FROM TABLE&selectedYear t1
GROUP BY
t1.Ano,
t1.IdComuna;
QUIT;

Are you familiar with Prompts in EG?

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 256 views
  • 0 likes
  • 2 in conversation