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;
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?
Use the Weight Statement in Proc Summary.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.