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.

 

CFC_SAS_Communities_400x225.jpgCFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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