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 Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.