BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I need to sum data across a row (layers) say for a road surface.

P=Pavement
M=Milling
B=Base

Such as P .30, P 1.0, P 4.0, M -4.0, P 2.0, B .70, P 2.3. If P represented the data i needed to sum from left to right, subtracting the M from only the numbers past the M.

A. (P .30 + P 1.0 + P 4.0) = 5.30

B. (M -4.0 - P 2.0 + B .70 + P 2.3) = 1


A. + B. = 6.3
2 REPLIES 2
Patrick
Opal | Level 21
In order to get a good answer you should provide us with a sample data set (a SAS data step creating a SAS table) and then tell us how the result should look like.

As a general answer to your question:
Use an ARRAY and loop over it.
deleted_user
Not applicable
CODE DEPTH
20 1.00 45 9.00 21.1 -4.75 08 1.00 06 0.50 08 1.50
20 0.75 21.1 -2.2 08 1.50 20 0.50 21.2 -2.00 08 1.25
20 0.75 21.1 -2.25 08 1.50 21.2 -2.00 08 1.25 25 9.00

I NEED TO GO ACROSS THE ROW FROM LEFT TO RIGHT, BUT IT HAS TO STEP FROM LEFT TO RIGHT DEPTH ONE +- DEPTH TWO AND SO ON AND SO FORTH. I CAN'T USE A SUM BECAUSE IT WILL ADD EVERYTHING THE SUBTRACT THE -'S FROM THE TOTAL. IF THERE IS A NEG NUMBER NEAR THE END SAY -3.00 THEN 2.00 THERE WOULD BE -1.00 LEFT I NEED THAT TO DELETE THEN.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 690 views
  • 0 likes
  • 2 in conversation