BookmarkSubscribeRSS Feed
sasowiczka123
Fluorite | Level 6

Hello, 
During analyzing financial data I came across a huge difficulty.  Variable "total salary" looks like this:

75,879.00 or 123,679.00 or 7,987.00. Do you know how to delete commas and periods? They occure in different places.

Please help

5 REPLIES 5
Reeza
Super User
What is the type and format applied on that variable? Is this after you've imported the data or something you're trying to do after you've imported the data?
ballardw
Super User

Please describe what you are doing that the presence of either the comma or the decimal affects your analysis.

 

You may also want to run proc contents on that data set and share the variable type and format currently associated with the variable.

I suspect that the current format is some form of CommaW.D. The presence of the commas or decimals are very unlikely to have any impact on analysis though possible will have an effect on some reports.

Shmuel
Garnet | Level 18

What is the origin of your data? is it excel or any other external file or data base?

How do you import that file into sas?

I believe that the issue is the result of method importing the data to sas.

biopharma
Quartz | Level 8

What is the variable type? Numeric that is formatted to display such or a character variable containing the above strings? Don't think you want to remove the period without also removing the zeroes that follow. Otherwise, it affects the value.

 

If it is a numeric variable type you can clear the format with:

format <variable> ;

 

If it is character, you can compress the comma out. I don't think you should delete the period as it would change the value. Here is a small demo:

 

900        data _null_ ;
901          x = "123,679.00" ;
902          y = compress(scan(x,1,".")) ;
903          put x = y = ;
904        run ;
 
x=123,679.00 y=123,679

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 5 replies
  • 5550 views
  • 0 likes
  • 6 in conversation