<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Calculate descriptive statistics on all variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501579#M133747</link>
    <description>&lt;P&gt;It appears that the unprocessed variables are of type character, not type numeric.&amp;nbsp; Proc means is intended to generates stats only for numeric variables.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Oct 2018 16:39:30 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2018-10-04T16:39:30Z</dc:date>
    <item>
      <title>Calculate descriptive statistics on all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501573#M133743</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=merge_bcbs N MEAN STDDEV MEDIAN MAX MIN maxdec=4;
	var type srxtype_n antif fracture;
			title '';
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;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&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 16:47:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501573#M133743</guid>
      <dc:creator>JUMMY</dc:creator>
      <dc:date>2018-10-04T16:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate descriptive statistics on all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501577#M133745</link>
      <description>&lt;P&gt;You can't compute statistics on&amp;nbsp; a character variable. SAS likely read a column in as character, when you want it as numeric.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run a PROC CONTENTS and check your variable types.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226541"&gt;@JUMMY&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=merge_bcbs N MEAN STDDEV MEDIAN MAX MIN maxdec=4;
	var type srxtype_n antif fracture;
			title '';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;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&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 16:38:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501577#M133745</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-04T16:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate descriptive statistics on all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501578#M133746</link>
      <description>&lt;P&gt;Please run&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=merge_bcbs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What types of variables are these?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 16:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501578#M133746</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-10-04T16:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate descriptive statistics on all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501579#M133747</link>
      <description>&lt;P&gt;It appears that the unprocessed variables are of type character, not type numeric.&amp;nbsp; Proc means is intended to generates stats only for numeric variables.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 16:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501579#M133747</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-10-04T16:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate descriptive statistics on all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501580#M133748</link>
      <description>And if you exclude a VAR statement entirely, SAS will run it for all numeric variables by default.</description>
      <pubDate>Thu, 04 Oct 2018 16:40:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501580#M133748</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-04T16:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate descriptive statistics on all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501583#M133749</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;. they are character variables. Is there a way to convert them to numeric and then do a proc means?</description>
      <pubDate>Thu, 04 Oct 2018 16:45:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501583#M133749</guid>
      <dc:creator>JUMMY</dc:creator>
      <dc:date>2018-10-04T16:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate descriptive statistics on all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501584#M133750</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;, they are character variables. Is there a way to convert them to numeric and then do a proc means?</description>
      <pubDate>Thu, 04 Oct 2018 16:46:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501584#M133750</guid>
      <dc:creator>JUMMY</dc:creator>
      <dc:date>2018-10-04T16:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate descriptive statistics on all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501591#M133753</link>
      <description>&lt;P&gt;If they are character variables, let's assume they contain nothing but blanks, contiguous numeric characters, and maybe one decimal point.&amp;nbsp; 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:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A couple of notes:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;YOu can't convert a character variable to a numeric variable.&amp;nbsp; I.e. a variable can only be one type for the duration of a data step.&amp;nbsp; That's why I did renames of the character variables above.&amp;nbsp; Then when the INPUT function was run, I could re-use the original variable names that you probably want to use in the proc means.&lt;/LI&gt;
&lt;LI&gt;The input function needs 2 arguments, the character variable name, and the format to apply.&amp;nbsp; I suspect that best32. format will serve your needs.&lt;/LI&gt;
&lt;LI&gt;(edited additional note).&amp;nbsp; Also, for efficiency's sake I made VNEED a data set "view", not a data set "file".&amp;nbsp; Assuming you don't need the numeric conversion to be permanent, there is no need to write data set need to a disk only to re-read it once.&amp;nbsp; A data set view avoids that process - instead it read from the original data set (HAVE), and transfers the content of data set need, one record at a time, to the proc means.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Thu, 04 Oct 2018 17:04:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501591#M133753</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-10-04T17:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate descriptive statistics on all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501597#M133757</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;, I am a new sas user. Pardon me. So what variables do I put under proc means?</description>
      <pubDate>Thu, 04 Oct 2018 17:12:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501597#M133757</guid>
      <dc:creator>JUMMY</dc:creator>
      <dc:date>2018-10-04T17:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate descriptive statistics on all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501598#M133758</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226541"&gt;@JUMMY&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;, they are character variables. Is there a way to convert them to numeric and then do a proc means?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;Or write a data step or modify the data step code created by Proc Import, copy from the log and edit.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 17:12:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501598#M133758</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-04T17:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate descriptive statistics on all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501604#M133761</link>
      <description>&lt;P&gt;That's a question easily answered by (1) reading one of &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s comments, or (2) experimenting (which I believe all programmers do - so welcome to the club).&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 17:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-descriptive-statistics-on-all-variables/m-p/501604#M133761</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-10-04T17:21:47Z</dc:date>
    </item>
  </channel>
</rss>

