BookmarkSubscribeRSS Feed
cbuon
Calcite | Level 5

Disclaimer: I'm brand new to SAS.  But I've created a new data set named "employee_info" and I cannot figure out how to change the variable type of the salary column to currency.  This is the code I get, which does not specify the individual variables:

Code for Employee_info.PNG

4 REPLIES 4
Reeza
Super User

PROC IMPORT doesn’t allow you to change types, but I don’t thing that’s your issue anyways. 

 

SAS only has two types, numeric and character. Which of those is your variable? There is a currency format that can be applied, which may be what you’re looking to do. 

 


@cbuon wrote:

Disclaimer: I'm brand new to SAS.  But I've created a new data set named "employee_info" and I cannot figure out how to change the variable type of the salary column to currency.  This is the code I get, which does not specify the individual variables:

Code for Employee_info.PNG


 

cbuon
Calcite | Level 5

Thank you for responding! The format type is numeric, how do I apply the currency format?

Reeza
Super User
data sample;
x= 100000;
format x dollar12.;
run;

proc print data=sample;run;

Use a FORMAT statement as above. 

Kurt_Bremser
Super User

When posting code and/or logs, follow the advice here: https://communities.sas.com/t5/help/faqpage/faq-category-id/posting?nobounce

Typing text from pictures is tedious and unnecessary work.

 

To add to @Reeza: assigning a format does not change the type or the contents of a variable (the type can't be changed at all), but it changes the way the contents are displayed. You still need to use the raw value in comparisons, for example.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 4 replies
  • 1096 views
  • 0 likes
  • 3 in conversation