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.

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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