BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Phil_NZ
Barite | Level 11

Hi all SAS Users,

Today I did things with Do...Loop and there is one thing quite ambiguous to me.

In the last demo of lesson 6 of Programming 2, you have the code as below:

 

Phil_NZ_0-1617703503898.png

 

I am wondering why do not you set up the statement 'Saving=0;' right after the statement 'Month=0' as the previous demo:

 

Phil_NZ_1-1617703622296.png

I know the results from the code is right, but why do not we add one more statement for resetting Saving=0, because from my point of view, the Saving of one person will be retained and need to be set up back to zero for calculating for the next person.

 

Warm regards,

 

 

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star
Most likely, the incoming data set contains SAVINGS. So the SET statement brings in a new value for each observation.

View solution in original post

4 REPLIES 4
Astounding
PROC Star
Most likely, the incoming data set contains SAVINGS. So the SET statement brings in a new value for each observation.
Al14
SAS Employee

Astounding is correct.  The pg2.savings2 table has a savings column.  When the set statement executes, it overwrites the savings value in the program data vector (PDV).

mkeintz
PROC Star

I guess the particulars of the question could be justified if the incoming data is annual, with a variable named AMOUNT representing an a monthly amount to be added for each year.

 

Then savings is a new variable to be generated representing accrued value of deposits plus monthly interest.

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

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!

5 Steps to Your First Analytics Project Using SAS

For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 672 views
  • 4 likes
  • 5 in conversation