<?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: vtype function in proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339412#M77424</link>
    <description>&lt;P&gt;Rreate a table with the required formats and use PUTC instead.&lt;/P&gt;
&lt;P&gt;You can then use a data step to get the types or a query to the Dictionary tables.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Mar 2017 20:09:32 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-03-08T20:09:32Z</dc:date>
    <item>
      <title>vtype function in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339372#M77413</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do we have any function in proc sql&amp;nbsp;which is equivalent to "vtype" in Data step?. This is to check whether the field is a character or numeric and based on that passing it through a condition.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;(Case when vtype(field) = 'C' then condition1 else condition2 end)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate&amp;nbsp;any thoughts and suggestions on this. Thanks, DU&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 19:29:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339372#M77413</guid>
      <dc:creator>Data_User</dc:creator>
      <dc:date>2017-03-08T19:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: vtype function in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339379#M77415</link>
      <description>&lt;P&gt;If only vtype would work in SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But maybe this is a way?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select 
case when (select type from dictionary.columns where libname='SASHELP' and memname='CLASS' and name='Name') = 'char' then 'CHAR' else 'NUM' end as coltype
from sashelp.class;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Will get tedious with many variables but it does get the job done. May you can macro-fy this to make it more shorter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 19:41:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339379#M77415</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2017-03-08T19:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: vtype function in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339383#M77418</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12460"&gt;@jklaverstijn&lt;/a&gt;&amp;nbsp;I am sorry, I am not able to understand it. Can you please suggest how can I achieve it from the below code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; check_v1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;infile&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;dsd&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;missover&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;dlm&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"#"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; var1 $ var2 $ var3 var4 var5;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;ND# ND#100#11#13&lt;/P&gt;&lt;P&gt;1500#ND#100#23#53&lt;/P&gt;&lt;P&gt;ND #1000#200#934#598&lt;/P&gt;&lt;P&gt;ND#ND #200#433#624&lt;/P&gt;&lt;P&gt;1000#2000#300#548#6889&lt;/P&gt;&lt;P&gt;1000#1000#300#548#6859&lt;/P&gt;&lt;P&gt;1000#2000#100#872#638&lt;/P&gt;&lt;P&gt;2000#3000#200#54987#879&lt;/P&gt;&lt;P&gt;2000#3000#200#549#548&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%MACRO&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; CH(VAR);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;CREATE TABLE CHECK_V2_&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;VAR.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; AS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;SELECT (case when vtype(&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;VAR.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'C'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; then STRIP(&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;VAR.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) else &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;VAR.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; end) AS GROUP,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;SUM(VAR3) AS SUM3,&lt;/P&gt;&lt;P&gt;SUM(VAR4) AS SUM4&lt;/P&gt;&lt;P&gt;FROM CHECK_V1&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;GROUP BY &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%MEND&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;CH&lt;/I&gt;&lt;/STRONG&gt;(VAR1);&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;CH&lt;/I&gt;&lt;/STRONG&gt;(VAR2);&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;CH&lt;/I&gt;&lt;/STRONG&gt;(VAR3);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;DU&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 19:47:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339383#M77418</guid>
      <dc:creator>Data_User</dc:creator>
      <dc:date>2017-03-08T19:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: vtype function in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339412#M77424</link>
      <description>&lt;P&gt;Rreate a table with the required formats and use PUTC instead.&lt;/P&gt;
&lt;P&gt;You can then use a data step to get the types or a query to the Dictionary tables.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 20:09:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339412#M77424</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-08T20:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: vtype function in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339457#M77439</link>
      <description>&lt;P&gt;&lt;FONT size="3" face="Courier New"&gt;You could use&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3" face="Courier New"&gt;select cats&lt;/FONT&gt;&lt;FONT size="3" face="Courier New"&gt;(&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" size="3" face="Courier New"&gt;VAR.&lt;/FONT&gt;&lt;FONT size="3" face="Courier New"&gt;) as GROUP&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3" face="Courier New"&gt;if you dont mind always making GROUP a string&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 22:01:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339457#M77439</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-03-08T22:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: vtype function in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339532#M77460</link>
      <description>&lt;PRE&gt;

You can make a macro variable to hold this:


data check_v1;
infile datalines dsd missover dlm="#";
input var1 $ var2 $ var3 var4 var5;
datalines;
ND# ND#100#11#13
1500#ND#100#23#53
ND #1000#200#934#598
ND#ND #200#433#624
1000#2000#300#548#6889
1000#1000#300#548#6859
1000#2000#100#872#638
2000#3000#200#54987#879
2000#3000#200#549#548
;
RUN;
%MACRO CH(VAR);
PROC SQL;
select case when type='char' then "STRIP(&amp;amp;VAR.)" else "&amp;amp;VAR." end as temp length=40
 into : condition
from dictionary.columns 
where libname='WORK' and memname='CHECK_V1' and upcase(name)="%upcase(&amp;amp;var)";

CREATE TABLE CHECK_V2_&amp;amp;VAR. AS
SELECT &amp;amp;condition AS GROUP,
SUM(VAR3) AS SUM3,
SUM(VAR4) AS SUM4
FROM CHECK_V1
GROUP BY 1;
QUIT;
%MEND;

%CH(VAR1)
%CH(VAR2)
%CH(VAR3)





&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Mar 2017 04:04:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339532#M77460</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-03-09T04:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: vtype function in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339645#M77516</link>
      <description>&lt;P&gt;Awesome. It's working. Thanks very much for this &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Really appreciate it..&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 14:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339645#M77516</guid>
      <dc:creator>Data_User</dc:creator>
      <dc:date>2017-03-09T14:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: vtype function in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339646#M77517</link>
      <description>&lt;P&gt;Thanks for contributing on this. I really appreciate it.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 14:35:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/vtype-function-in-proc-sql/m-p/339646#M77517</guid>
      <dc:creator>Data_User</dc:creator>
      <dc:date>2017-03-09T14:35:05Z</dc:date>
    </item>
  </channel>
</rss>

