BookmarkSubscribeRSS Feed
Watkins155
Calcite | Level 5
Good afternoon,
 
I am trying to compute weighted means for my dataset. Attached is a screenshot of the dataset I'm working with. Below is the code I am using and the error that I am getting. Essentially I am computing the means of the prevalence weighted by the sample size and I want it to be done by parasite class.
 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
59
60 proc means data=ANTH.capprevanth mean median;
61 class parasites ;
62 weight samplesize2 ;
ERROR: Variable SAMPLESIZE2 not found.
63 var prevalence ;
64 run;
 
When I tried to type in the name with spaces, I receive the following error:
 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
59
60 proc means data=ANTH.capprevanth mean median;
61 class parasites ;
62 weight sample size 2 ;
____
22
202
ERROR: Variable SAMPLE not found.
ERROR 22-322: Expecting ;.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
63 var prevalence ;
64 run;
 
Any ideas how I can solve this? I'm thinking it is a small error, but I am not sure what it is. Thank you.
 
2 REPLIES 2
Reeza
Super User

You have the variables names incorrect. 

Run a PROC CONTENTS and see the exact variable names you need to use. 

SuzanneDorinski
Lapis Lazuli | Level 10

From your screen shot, it looks like you are using SAS Studio, viewing column labels, like this example:

 

SAS Studio data set viewer showing column labelsSAS Studio data set viewer showing column labels

 

As Reeza mentioned, you could run PROC CONTENTS on your data set.  Or you could switch the view to column names, as shown below:

 

SAS Studio data set viewer showing column namesSAS Studio data set viewer showing column names

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 746 views
  • 1 like
  • 3 in conversation