<?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: Couting total numeric variables and character variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Couting-total-numeric-variables-and-character-variables/m-p/42890#M11184</link>
    <description>Try this,&lt;BR /&gt;
proc contents data=libname.datasetname out=Column_Name_Type(keep = NAME TYPE) noprint;&lt;BR /&gt;
run;&lt;BR /&gt;
it will create a dataset with all column names and their types.</description>
    <pubDate>Thu, 01 Jul 2010 10:30:20 GMT</pubDate>
    <dc:creator>DataShare</dc:creator>
    <dc:date>2010-07-01T10:30:20Z</dc:date>
    <item>
      <title>Couting total numeric variables and character variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Couting-total-numeric-variables-and-character-variables/m-p/42889#M11183</link>
      <description>Hi all, &lt;BR /&gt;
&lt;BR /&gt;
This is my first post in this forum. It is just out of curiousness to learn.&lt;BR /&gt;
&lt;BR /&gt;
I want to&lt;BR /&gt;
&lt;BR /&gt;
1. Count how many of the variables in a data set are numeric and how many are character&lt;BR /&gt;
&lt;BR /&gt;
2. Create a two different files; file 1 containing only numeric variables and file 2 containing only character variables.&lt;BR /&gt;
&lt;BR /&gt;
I know we can use the function vtype() to find out if a variable is char or numeric .. &lt;BR /&gt;
&lt;BR /&gt;
But, if you have thousand variables then how would you do it without having to know the name of that variable...&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I thought of using an array .. but then an array can be either char or numeric so using an array is out of question I think...&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thank you,&lt;BR /&gt;
&lt;BR /&gt;
Rockerd. &lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;&lt;/B&gt;&lt;U&gt;&lt;/U&gt;&lt;I&gt;&lt;/I&gt;&lt;B&gt;&lt;/B&gt;&lt;B&gt;&lt;/B&gt;</description>
      <pubDate>Thu, 01 Jul 2010 08:47:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Couting-total-numeric-variables-and-character-variables/m-p/42889#M11183</guid>
      <dc:creator>rockerd</dc:creator>
      <dc:date>2010-07-01T08:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Couting total numeric variables and character variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Couting-total-numeric-variables-and-character-variables/m-p/42890#M11184</link>
      <description>Try this,&lt;BR /&gt;
proc contents data=libname.datasetname out=Column_Name_Type(keep = NAME TYPE) noprint;&lt;BR /&gt;
run;&lt;BR /&gt;
it will create a dataset with all column names and their types.</description>
      <pubDate>Thu, 01 Jul 2010 10:30:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Couting-total-numeric-variables-and-character-variables/m-p/42890#M11184</guid>
      <dc:creator>DataShare</dc:creator>
      <dc:date>2010-07-01T10:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Couting total numeric variables and character variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Couting-total-numeric-variables-and-character-variables/m-p/42891#M11185</link>
      <description>You will want to consult the documentation for "SAS Variable Lists".&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#/documentation/cdl/en/lrcon/62955/HTML/default/a000695105.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#/documentation/cdl/en/lrcon/62955/HTML/default/a000695105.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; 1. Count how many of the variables in a data set are&lt;BR /&gt;
&amp;gt; numeric and how many are character&lt;BR /&gt;
&lt;BR /&gt;
You can use PROC CONTENTS as suggested or the dictionary tables or in a data step as &lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
548  data _null_;&lt;BR /&gt;
549     if 0 then set sashelp.shoes;&lt;BR /&gt;
550     array _n&lt;LI&gt; _numeric_;&lt;BR /&gt;
551     array _c&lt;/LI&gt;&lt;LI&gt; _char_;&lt;BR /&gt;
552     n=dim(_n);&lt;BR /&gt;
553     c=dim(_c);&lt;BR /&gt;
554     putlog 'NOTE: ' n= c=;&lt;BR /&gt;
555     stop;&lt;BR /&gt;
556     run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: n=4 c=3&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; 2. Create a two different files; file 1 containing&lt;BR /&gt;
&amp;gt; only numeric variables and file 2 containing only&lt;BR /&gt;
&amp;gt; character variables.&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; I know we can use the function vtype() to find out if&lt;BR /&gt;
&amp;gt; a variable is char or numeric .. &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; But, if you have thousand variables then how would&lt;BR /&gt;
&amp;gt; you do it without having to know the name of that&lt;BR /&gt;
&amp;gt; variable...&lt;BR /&gt;
&lt;BR /&gt;
Again using a "SAS Variable List".&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
580  data num(keep=_numeric_) chr(keep=_char_);&lt;BR /&gt;
581     set sashelp.class;&lt;BR /&gt;
582     run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: There were 19 observations read from the data set SASHELP.CLASS.&lt;BR /&gt;
NOTE: The data set WORK.NUM has 19 observations and 3 variables.&lt;BR /&gt;
NOTE: The data set WORK.CHR has 19 observations and 2 variables.&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;/LI&gt;</description>
      <pubDate>Thu, 01 Jul 2010 11:48:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Couting-total-numeric-variables-and-character-variables/m-p/42891#M11185</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-07-01T11:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Couting total numeric variables and character variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Couting-total-numeric-variables-and-character-variables/m-p/42892#M11186</link>
      <description>Thank you for the reply.&lt;BR /&gt;
&lt;BR /&gt;
I had used _numeric_ in the past but never realized it could be used here as well &lt;BR /&gt;
&lt;BR /&gt;
I guess your solution is a good way to get around this</description>
      <pubDate>Thu, 01 Jul 2010 14:17:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Couting-total-numeric-variables-and-character-variables/m-p/42892#M11186</guid>
      <dc:creator>rockerd</dc:creator>
      <dc:date>2010-07-01T14:17:53Z</dc:date>
    </item>
  </channel>
</rss>

