BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
yadaw
Fluorite | Level 6

Hello All,

 

I want to check the data type of a variable within a DATASET. Is there any function to check this?

I meant in other programming like PYTHON, we have type() to check the datatype of variable.

 

For Example:

DATA test;

        empName = 'Rob'; 

        empSal = 2000; 

        typeOfEmpName = /* need function here that will take empName as an argument and return the type*/

        typeOfEmpSal = /* need function here that will take empSal as an argument and return the type*/

RUN;

 

Thanks, 

P Yadaw

1 ACCEPTED SOLUTION
3 REPLIES 3
yadaw
Fluorite | Level 6

Thank you, It returns, C for character and N for numeric datatype.

Patrick
Opal | Level 21

Here you go:

DATA test;
  empName = 'Rob';
  empSal = 2000;
  typeOfEmpName = vtype(empName); /* need function here that will take empName as an argument and return the type*/
  typeOfEmpSal = vtype(empSal);   /* need function here that will take empSal as an argument and return the type*/
RUN;
proc print data=test;
run;

The way I normally find functions quickly.

I go to the docu where I've got all functions listed by category like here.

Then I either just search in the browser - for your case here I've just searched with keyword type - or I go to the relevant category and just browse over the descriptions. ...or I know a function name related to what I need, search for this one and then look within the same category if there is something suited.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 2951 views
  • 2 likes
  • 3 in conversation