BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MeganE
Pyrite | Level 9

Hi,

 

I inherited this code:

            proc sql;
                create table junk.k5_sex_2003 as
                select sex, 2003 as year, (sum(payamt) / sum(yar)) as value
                from junk.py_2003b (where=(mod1 in (1 2 3 4)))
                group by sex.;
            quit;

 

And i don't think it's working right, so i'd like to recreate it in something else, but i don't know enough about proc means/tabulate/summary to do it.

 

The only part i want to double check is:

(sum(payamt) / sum(yar)) as value,

by var

 

What's the best way to do this calculation another way other than proc sql?  There are way too many records to do it by hand.

 

Thanks

Megan

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Here's the proc means code, which will create the sum variables and then you'll need to do the division by hand or another data step.

 

proc means data=junk.py_2003b sum nway;
where mod1 in (1 2 3 4);
class sex;
var payamt yar;
output out=totals sum(payamt yar) = tot_payamt tot_var;
run;

data check_value;
set totals;

value = tot_payamt/tot_var;
run;

View solution in original post

2 REPLIES 2
Reeza
Super User

Here's the proc means code, which will create the sum variables and then you'll need to do the division by hand or another data step.

 

proc means data=junk.py_2003b sum nway;
where mod1 in (1 2 3 4);
class sex;
var payamt yar;
output out=totals sum(payamt yar) = tot_payamt tot_var;
run;

data check_value;
set totals;

value = tot_payamt/tot_var;
run;
MeganE
Pyrite | Level 9

Thanks!  Gave me the exact same numbers.  Guess it was working, lol.  🙂

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!

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
  • 2 replies
  • 762 views
  • 0 likes
  • 2 in conversation