How to divide two queries output

Reply
Occasional Contributor
Posts: 13

How to divide two queries output

[ Edited ]

I want to count a numebr of cell from two different Column (column may be Numerical & String)and then want to divide them afterward wanna save the result in Cell or Variable.

 

 

For Example I have two data set 1)vivosl.int and 2)vivosl.rev , here i want to use one column from first data set and one column from second data set. 

 

count(FirstDataSet.column) / count(SecondDataSet.column);

 

What would be the query i have to use for this?

Now i am using following query,

 

proc sql;
select count(Name) from vivosl.int / (select count(Name) from vivosl.rev);
quit;

 

But its not working. Can you suggest me feasible way to get a output?

Super User
Posts: 11,128

Re: How to divide two queries output

First you have describe in more detail what you are doing. From your attempted code you would probably be better off summarizing each data set separately. Possibly if you are stuck on using SQL

 

proc sql;
   create table count1 as
   select count(name) as IntNameCount
   from vivosl.int;
   create table count2 as 
   select count(name) as RevNameCount
   from vivosl.rev;
   select IntNameCount/RevNameCount as Ratio
   from count1, count2;
quit;

I am sure there are slicker ways but this should work.

 

Occasional Contributor
Posts: 13

Re: How to divide two queries output

That's awesome!! Thank you some much :-)
Occasional Contributor
Posts: 13

How to divide two queries output

[ Edited ]

I want to count a numebr cell in two different Column (column may be Numerical & String)and then want to divide them afterward wanna save the result in Cell or Variable.

 

 

 

 

Super User
Posts: 11,128

Re: How to divide two queries output

Please provide some example input, what the desired output of than input data should be and whether you want a SAS dataset or document such as Word or Excel for output.

Occasional Contributor
Posts: 13

Re: How to divide two queries output

[ Edited ]

proc sql;
select count(Name) from vivosl.int / (select count(Name) from vivosl.rev);
quit;

Respected Advisor
Posts: 4,816

Re: How to divide two queries output

You were close:

 

proc sql;
select count(Name) / (select count(Name) from vivosl.rev) from vivosl.int;
quit;
PG
Occasional Contributor
Posts: 13

Re: How to divide two queries output

Wow! Thanks for this ....... Fabulous
Ask a Question
Discussion stats
  • 7 replies
  • 378 views
  • 0 likes
  • 3 in conversation