BookmarkSubscribeRSS Feed
siddharthpeesary
Calcite | Level 5

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

1 REPLY 1
Patrick
Opal | Level 21

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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 2359 views
  • 0 likes
  • 2 in conversation