BookmarkSubscribeRSS Feed
vivekarun12
Calcite | Level 5

hi.. am new to SAS, I need to insert a query(eg - select count(distict inc_no) from incident_table) into the table using Dataset.
Second thing is i need to fetch that column and run a proc sql, i mean i need an ouput(count - 60) for the query which has been inserted in the incident_table.
How can i acheive this, pls anyone help me. Thanks in advance.

10 REPLIES 10
LinusH
Tourmaline | Level 20

Not sure about the purpose of this, perhaps you could clarify the underlying requirement?

But technically, just store the query in a char column in a table.

Then you can use call execute in a data step that reads that table.

Data never sleeps
vivekarun12
Calcite | Level 5

Sorry for delay in respond, I have inserted a data in the table, fyr, 

make

select count(make) from auto

I need an output of the above query, how can i get it. thanks.

Reeza
Super User

Look into CALL EXECUTE or DOSUBL

vivekarun12
Calcite | Level 5

Reeza.. Call execute is not working for me. am new to SAS.. can yu pls share some example pgm..? pls check my code below..
proc sql;
select make from auto
where
make like 'selec%';
call execute (make);
run;

Thanks in advance..

vivekarun12
Calcite | Level 5

Anyone pls help on my below query... 

Call execute is not working for me. am new to SAS.. can yu pls share some example pgm..? pls check my code below..
proc sql;
select make from auto
where
make like 'selec%';
call execute ("PROC SQL;");
run;

Thanks in advance..

 

Reeza
Super User

You don't need anything actually. Your question was confusing. 

Submit the following program

 

 

Proc SQL;

select make

from auto

where make like 'selec%';

quit;

 

See here for basic SAS tutorials as well as links to the free ecourse. 

vivekarun12
Calcite | Level 5

Thanks for your respond. for your query am getting a result like,

make
select count(make) from auto group by mpg
there is a query in the variable as shown above, I have got an ouput from your query, what i want is, i need an output for the above query(select count(make) from auto group by mpg) from the variable. 

ballardw
Super User

It really helps to show some example data. If you have a data set then instructions here https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to create SAS datastep code that can be posted here as text so that we can recreate the intput data.

 

Then show what the desired result for that data.

You are starting in the middle and the desired output is not clear.

Reeza
Super User

I'm sorry, but it's incredibly unclear on what you're trying to achieve. I can't tell if its a very basic question where you want to run a query and get results or if its something more complex where you're trying to store code in a data set and then execute said code.

 

Please post in more details what you're trying to do, and try and include examples/samples as much as possible.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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