BookmarkSubscribeRSS Feed
Jyuen204
Obsidian | Level 7

I have a table built with integer values (Table X)

 

Column 1  Column 2
A               1

B               2

C               10

I have a secondary table (Table Y) built with Decimal variables to contain a calculated number based on Table X

proc sql;

(select sum(Column 2) from Table X where  Column 1 like ('A', 'B') ) /

(select Column 2 from Table X where Column 1 = 'C');

Run;

 

I am trying to run this calculation but am getting an error

 

ERROR 22-322: Syntax error, expecting one of the following: ;, EXCEPT, INTERSECT, ORDER, OUTER, UNION.

5 REPLIES 5
PaigeMiller
Diamond | Level 26

Although you mention you have table Y, it doesn't seem to appear in your description of the problem.

 

Where does it come into use?

 

 

--
Paige Miller
Jyuen204
Obsidian | Level 7

I am going to be insterting the caluclated value into Table Y. I suppose it's not relevant here because my issue is the calculation part.

PaigeMiller
Diamond | Level 26

Show us the log of this PROC SQL step. We need to see the entire LOG, not just the error message. To preserve the formatting and make the log readable, please click on the {i} icon and paste the log into the window that appears — do not skip this step.

--
Paige Miller
PGStats
Opal | Level 21

Proper syntax could be:

 

proc sql;
create table Y as
	sum((column1 like ('A', 'B'))*Column2) / 
	sum((column1 = 'C')*Column2) as Ratio
from X;
quit;
PG
FreelanceReinh
Jade | Level 19

Or try the third step of this example:

data X;
input Column1 $ Column2;
cards;
A 1
B 2
C 10
;

proc sql;
create table Y (z num);
quit;

proc sql;
insert into Y
select
(select sum(Column2) from X where Column1 in ('A', 'B')) / Column2
from X where Column1 = 'C';
quit;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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