BookmarkSubscribeRSS Feed
jwhite
Quartz | Level 8

(new DI Studio user)

(SAS 9.3)

Good Afternoon, All.

I've got a table with a numeric column that has some observations containing too many trailing zeroes. For example, there should be no number over 90 in this column so if there is a 400, it should be a 4, if there is a 1200 it should be 12.

So, I think I'll need to do a proc sql step to go through the table looking for values over 90. Then, how do I remove the last two characters in that observation? Would I need to convert the format to character first and use a substring function or can I do this while the value is numeric?

Also, what's a quick way to increment a counter within this where statement that I can output in the log only, so I'll have an idea of how many observations are being updated?

Thanks!

-Jeff

2 REPLIES 2
jakarman
Barite | Level 11

Numeric columns...... These are binary we are in the digital age. Those 0's are at the best a result of a conversion from binary to decimal and that decimal is of character type.

Converting character (decimals) to numeric digital binary can be done wit an indicator of the decimal point.   It looks you are referring to an external DBMS having a character field containing decimals in hundreds.       

---->-- ja karman --<-----
ballardw
Super User

data want;

     set have;

     if value > 90 then value = int(value/100); /* or Floor(value/100) */

run;

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