Hello every one,
could you please tell me how to run a proc means/summary on character variiables:
proc means data=x print missing n nmiss;
var _CHARACTER_;
ods output summary=y;
run;
the above code is returning an error.
Please provide some sample input data in the form of a data step (as per this article) and also show the log containing the error message you have.
Thanks
Amir.
Hi @aloou ,
Do you want to use character variables to calculate statistics on categories?
if so, you can add the "class" statement.
You can't use char-variables in the var-statement.
@aloou wrote:
could you please tell me how to run a proc means/summary on character variiables:
Could you please tell us what you would like PROC MEANS or PROC SUMMARY to do with your character variables? You can't compute a mean of character variables. You can't compute a standard deviation. So what is the desired output of PROC MEANS or PROC SUMMARY (or any other procedure) from your character variables?
Perhaps you want to use PROC FREQ on character variables? PROC FREQ produces a count (and percent) of each level of your character variables.
Mr Paige i hope that you are doing well.
Yess thats exactly what i want to do, count and percentage of char type variables.
Hi @aloou ,
So you should use PROC FREQ. Here is the basic syntax:
proc freq data=have noprint;
table var_char / out=want;
run;
Usine SQL instead.
proc sql; select n(sex) as n,nmiss(sex) as nmiss from sashelp.class; quit;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.