N stands for "Numeric" and C stands for 'Character'
(CASE
WHEN VTYPE(A.&FIRST)='N' AND A.&FIRST IS NOT NULL AND B.&SECOND IS NULL THEN A.&FIRST ELSE 0 END) AS NUMERIC_WRONG,
(CASE
WHEN VTYPE(A.&FIRST)='C' AND A.&FIRST IS NOT NULL AND B.&SECOND IS NULL THEN A.&FIRST ELSE '' END) AS CHARACTER_WRONG,
I have to seperate the buckets for character and numeric values in NUMERIC_WRONG and CHARACTER_WRONG for one field..
The VTYPE function is working for DATA STEP but not for proc SQL. can any one tell me there is any function for proc sql which works same as VTYPE.
Your help is much appreciated. Thanks
Your code snippet looks to me like you're overcomplicating something and that there must be a better solution. But then it doesn't show enough of what you have and want to achieve to really know.
Below would work in a SQL - doesn't mean I recommend doing it this way...
proc sql;
select
(select type from dictionary.columns where libname='SASHELP' and memname='CLASS' and upcase(name)='SEX') as vtype_name,
case
when
(select type from dictionary.columns where libname='SASHELP' and memname='CLASS' and upcase(name)='AGE') = 'num' then '1'
else '0'
end
as vtype_ind_age
from sashelp.class
;
quit;
SAS is headed back to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team.
Interested in speaking? Content from our attendees is one of the reasons that makes SAS Innovate such a special event!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.