BookmarkSubscribeRSS Feed
drteju
Fluorite | Level 6

I have created variables for multiple conditions based on whether the response to having them was yes or no. And a new variable for whether before a policy was implemented or after (year_class). Now, I want to create a table with weighted counts and percentages for each of these conditions. I am not sure how to create one table for all conditions. At the moment I am using below code to get the count for each condition(angipecev, cerebpalev,etc) where would the weight statement go here? How do I get one table for all conditions with weighted percentages? I have not used SAS much so apologies if this is something as easy as a Table statement could have done. Thank you in advance for the help. 

 

proc sql;

select distinct count(nhispid) INTO: count
from thesis.mydata
where year_class=1 and angipecev=1;
quit;

2 REPLIES 2
ballardw
Super User

Proc SQL is not meant to do "weighted" anything. You can force it but takes more work.

What is wrong with Proc Freq, Means, Report or Tabulate to make a weighted table?

Try this:

 

Proc freq data=thesis.mydata;
   tables nhispid;
   weight <what ever variable you have for weighting>;
   where year_class=1 and angipecev=1;
run;

You should be prepared to share some example data the actual desired or expected result.

I am almost afraid that the way you have phrased your question with "I have created variables for multiple conditions based on whether the response to having them was yes or no" that the way you did that may make it harder to do analysis.

 

And what did you expect to do with that macro variable?

 

 

PeterClemmensen
Tourmaline | Level 20

Use the Weight Statement in Proc Summary.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

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