BookmarkSubscribeRSS Feed
Kody_devl
Quartz | Level 8

Hi,

 

I am a developer who is new to SAS.

 

I have a table, myData that has three columns, BAL1, BAL2, and RUNOFF.

 

How can I easily, via some kind of datastep or proc SQL, update the RUNOFF  = (BAL1-BAL2) (for all of the rows)?

 

There are no more that  50,000 rows / obs in myData.

 

Many Thanks

 

Kody_Devl

 

 

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

You may want to run through the SAS free online videos to get a graps of the language if you are new:

data want;
  set have;
  runoff=bal1-bal2;
run;

Assumes of course that all three variables are the same type = numeric.  It doesn't matter the number of observations - much like a cursor in SQL, a datastep is a loop of ever observation in the dataset, so that formula gets applied to each row.

Kody_devl
Quartz | Level 8

It didn't work.

 

The Bal1 and Bal2 and RunOff are all Numeric 8

 

BEFORE UPDATE:

  Bal1           Bal2          RunOff

-154385          0               0

 

AFTER UDPATE;

 

  Bal1           Bal2          RunOff

-154385          0               

 

I then ran a query to Calculate RunOff and the query returned the same results for RunOff, Blank

 

Code Used:

data Work.Data_P2_0;

set Work.Data_P2;

runoff=PremiumWO0-PremiumWO1;

run;

 

LinusH
Tourmaline | Level 20
Odd. Any message in the log? Are all variables numeric?
Data never sleeps
Kody_devl
Quartz | Level 8

No Errors: 0

No Warnings: 0

 

This is why I am asking for help. 

This shouldn't be that hard but somthing is wrong.

Could it be some kind of formatting problem on the numeric 8 field.

 

The Zero fields were created by SQL when the table is created

 

0 as PremiumWO1

0 as RunOff

 

??

Kody_devl
Quartz | Level 8

I have imported the code but am having trouble with the correct parameters to get it to work.  I will have to play with it a bit.

 

Thanks

 

Kody_devl

 

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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