- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am getting a Proc Means error that the variables cannot be found. (Errors in image 1). I have run the Proc Contents to verify the variable names (Image 2). I have tried running this with and without the ClassData argument.
CAR_10, CAR_01, etc are all variables that I would like to compute the means for (each variable's mean individually). Ideally, I would like to do this by the variable "Type" in the dataset "biotech_list" (Image3).
Can someone tell me what I'm doing wrong?
/* Mean CARs for all mergers */
data temp.FirmLevelCars_sort; set temp.FirmLevelCars_sort;
run;
proc means data=temp.FirmLevelCars_sort nway noprint;
classdata=stat.biotech_list; by type;
var car_01 car_11 car_10 car_02 car_05;
label car_01 = '(0,1)';
label car_11 = '(-1,1)';
label car_10 = '(-1,0)';
label car_02 = '(0,2)';
label car_05 = '(0,5)';
title 'Table 2 Panel B';
run;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Here is a hint:
Show us the log and the results from running this code:
proc contents data=temp.FirmLevelCars_sort ; run; proc means data=temp.FirmLevelCars_sort nway noprint; by type; var car_01 car_11 car_10 car_02 car_05; label car_01 = '(0,1)'; label car_11 = '(-1,1)'; label car_10 = '(-1,0)'; label car_02 = '(0,2)'; label car_05 = '(0,5)'; title 'Table 2 Panel B'; run;
You may have had the variables in one version of the set temp.FirmLevelCars but you may have done something that removed one or more of them.
If you are learning to use SAS do not use the structure:
data temp.FirmLevelCars_sort; set temp.FirmLevelCars_sort; run;
First, that particular example does nothing except consume computer clock time. Second, when you have the same name data set on the SET and DATA statements you completely replace the data set. So some forms of logic errors can remove variables or change values and you can't ever use the original values you think are there. You would have to go back to previous steps to completely recreate the data set. While learning to use SAS you are very likely to make many logic errors.
Copy the log from the Proc contents through the proc means and show the result. Paste the copied log into a code box.
BTW. I suspect the Proc means you show won't run even after you remove the CLASSDATA erroneous statement as you have NOPRINT without an OUT= statement. So you have in effect told proc means not to generate anything.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The CAR_xx variables are in FirmLevelCARs_sort which I want the means for (by variable). "Type" is in the dataset biotech_list. It is a categorical variable with values H or V. Although not necessary, having the CAR_xx variables split by this categorical variable would save me several future steps.
Sorry if my original post wasn't clear
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Be aware that Classdata is an option to the PROC MEANS Statement. As of now, you use it as a Statement of its own. See the not below
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The obvious reason would be that the Car_xx variables are not in the input data set 🙂 Be aware that they should be in temp.FirmLevelCars_sort;..
Please run
proc contents data=temp.FirmLevelCars_sort;
run;
and post the results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Here is the proc contents output:
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Here is a hint:
Show us the log and the results from running this code:
proc contents data=temp.FirmLevelCars_sort ; run; proc means data=temp.FirmLevelCars_sort nway noprint; by type; var car_01 car_11 car_10 car_02 car_05; label car_01 = '(0,1)'; label car_11 = '(-1,1)'; label car_10 = '(-1,0)'; label car_02 = '(0,2)'; label car_05 = '(0,5)'; title 'Table 2 Panel B'; run;
You may have had the variables in one version of the set temp.FirmLevelCars but you may have done something that removed one or more of them.
If you are learning to use SAS do not use the structure:
data temp.FirmLevelCars_sort; set temp.FirmLevelCars_sort; run;
First, that particular example does nothing except consume computer clock time. Second, when you have the same name data set on the SET and DATA statements you completely replace the data set. So some forms of logic errors can remove variables or change values and you can't ever use the original values you think are there. You would have to go back to previous steps to completely recreate the data set. While learning to use SAS you are very likely to make many logic errors.
Copy the log from the Proc contents through the proc means and show the result. Paste the copied log into a code box.
BTW. I suspect the Proc means you show won't run even after you remove the CLASSDATA erroneous statement as you have NOPRINT without an OUT= statement. So you have in effect told proc means not to generate anything.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Do you have any errors prior to that error of variable not found? I'm guessing your data isn't sorted and that's the second error you receive and if you sort the data first then you'll be fine.
proc sort data=temp.firmLevelCars_sort out=firmlevelcars_sort;
by type;
run;
proc means data=FirmLevelCars_sort nway noprint;
by type;
var car_01 car_11 car_10 car_02 car_05;
label car_01 = '(0,1)';
label car_11 = '(-1,1)';
label car_10 = '(-1,0)';
label car_02 = '(0,2)';
label car_05 = '(0,5)';
title 'Table 2 Panel B';
run;
@ballardw wrote:
Here is a hint:
Show us the log and the results from running this code:
proc contents data=temp.FirmLevelCars_sort ; run; proc means data=temp.FirmLevelCars_sort nway noprint; by type; var car_01 car_11 car_10 car_02 car_05; label car_01 = '(0,1)'; label car_11 = '(-1,1)'; label car_10 = '(-1,0)'; label car_02 = '(0,2)'; label car_05 = '(0,5)'; title 'Table 2 Panel B'; run;You may have had the variables in one version of the set temp.FirmLevelCars but you may have done something that removed one or more of them.
If you are learning to use SAS do not use the structure:
data temp.FirmLevelCars_sort; set temp.FirmLevelCars_sort; run;First, that particular example does nothing except consume computer clock time. Second, when you have the same name data set on the SET and DATA statements you completely replace the data set. So some forms of logic errors can remove variables or change values and you can't ever use the original values you think are there. You would have to go back to previous steps to completely recreate the data set. While learning to use SAS you are very likely to make many logic errors.
Copy the log from the Proc contents through the proc means and show the result. Paste the copied log into a code box.
BTW. I suspect the Proc means you show won't run even after you remove the CLASSDATA erroneous statement as you have NOPRINT without an OUT= statement. So you have in effect told proc means not to generate anything.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Tango_Mike wrote:
Thank you all for the help. The problem was a dataset step and then the dataset was also not sorted correctly. I appreciate the tips today!
For many purposes you can use a CLASS statement instead of BY to group values. The sort is then done internally. Output data sets would however have a _type_ variable to indicate the combination of the class variables used for any output record and the TYPE or WAYS statement, NWAYS proc option or CLASSDATA data set proc option may be used to control the combinations of class variables in the output.