BookmarkSubscribeRSS Feed
aloou
Obsidian | Level 7

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.

7 REPLIES 7
Amir
PROC Star

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.

ed_sas_member
Meteorite | Level 14

Hi @aloou ,

 

Do you want to use character variables to calculate statistics on categories?

if so, you can add the "class" statement.

 

andreas_lds
Jade | Level 19

You can't use char-variables in the var-statement.

PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
aloou
Obsidian | Level 7

Mr Paige i hope that you are doing well.

 

Yess thats exactly what i want to do, count and percentage of char type variables.

ed_sas_member
Meteorite | Level 14

Hi @aloou ,

 

So you should use PROC FREQ. Here is the basic syntax:

proc freq data=have noprint;
   table var_char / out=want;
run;

 

Ksharp
Super User

Usine SQL instead.

 

proc sql;
select n(sex) as n,nmiss(sex) as nmiss
 from sashelp.class;
quit;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 7 replies
  • 9383 views
  • 2 likes
  • 6 in conversation