proc means data=merge_bcbs N MEAN STDDEV MEDIAN MAX MIN maxdec=4;
var type srxtype_n antif fracture;
title '';
run;
400 proc means data=merge_bcbs N MEAN STDDEV MEDIAN MAX MIN maxdec=4; 401 var type; 402 title ''; 403 run; NOTE: There were 100 observations read from the data set WORK.MERGE_BCBS. NOTE: PROCEDURE MEANS used (Total process time): real time 0.03 seconds cpu time 0.03 seconds 404 proc means data=merge_bcbs N MEAN STDDEV MEDIAN MAX MIN maxdec=4; 405 var type srxtype_n antif fracture; ERROR: Variable srxtype_n in list does not match type prescribed for this list. ERROR: Variable antif in list does not match type prescribed for this list. ERROR: Variable fracture in list does not match type prescribed for this list. 406 title ''; 407 run; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE MEANS used (Total process time): real time 0.01 seconds cpu time 0.01 seconds
I am trying calculate descriptive statistics on all variables I created (inserted above in proc step). I keep getting an error message that the variable does not match the prescribed list. Most of my variables are character. How do I run proc means on character variables. IS there a way to convert it to numeric? What am I doing wrong?
You can't compute statistics on a character variable. SAS likely read a column in as character, when you want it as numeric.
Run a PROC CONTENTS and check your variable types.
@JUMMY wrote:
proc means data=merge_bcbs N MEAN STDDEV MEDIAN MAX MIN maxdec=4; var type srxtype_n antif fracture; title ''; run;
400 proc means data=merge_bcbs N MEAN STDDEV MEDIAN MAX MIN maxdec=4; 401 var type; 402 title ''; 403 run; NOTE: There were 100 observations read from the data set WORK.MERGE_BCBS. NOTE: PROCEDURE MEANS used (Total process time): real time 0.03 seconds cpu time 0.03 seconds 404 proc means data=merge_bcbs N MEAN STDDEV MEDIAN MAX MIN maxdec=4; 405 var type srxtype_n antif fracture; ERROR: Variable srxtype_n in list does not match type prescribed for this list. ERROR: Variable antif in list does not match type prescribed for this list. ERROR: Variable fracture in list does not match type prescribed for this list. 406 title ''; 407 run; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE MEANS used (Total process time): real time 0.01 seconds cpu time 0.01 seconds
I am trying calculate descriptive statistics on all variables I created (inserted above in proc step). I keep getting an error message that the variable does not match the prescribed list. What am I doing wrong?
Please run
proc contents data=merge_bcbs;
run;
What types of variables are these?
It appears that the unprocessed variables are of type character, not type numeric. Proc means is intended to generates stats only for numeric variables.
If they are character variables, let's assume they contain nothing but blanks, contiguous numeric characters, and maybe one decimal point. One can deal with fancier character vars (say with currency symbols, commas, etc.) but the point here is to demonstrate the INPUT function, usually (but not exclusively) used to convert a character value into a numeric value:
data vneed / view=vneed;
set have (rename=(srxtype_n=chrv1 antif=chrv2 fracture=chrv3));
srxtype_n=input(chrv1,best32.);
antif_n=input(chrv2,best32.);
fracture_n=input(chrv3,best32.);
put (_character_) (=) / (_numeric_) (=);
run;
proc means data=vneed;
var ...... ;
run;
A couple of notes:
That's a question easily answered by (1) reading one of @Reeza's comments, or (2) experimenting (which I believe all programmers do - so welcome to the club).
@JUMMY wrote:
@mkeintz, they are character variables. Is there a way to convert them to numeric and then do a proc means?
Go back to when you read the data into SAS. Read the values as intended. If the source data was Excel convert to CSV first.
With CSV you can use Proc Import option guessingrows to read more rows before guessing the variable type, use a large value such as 32000.
Or write a data step or modify the data step code created by Proc Import, copy from the log and edit.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.