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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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