Calcite | Level 5

## find the attached code below and write code to find solution dynamically not chatgpt code please

data accounts;
input accno age amount;
cards;
101 23 2000
102 32 3000
103 21 1300
104 38 2100
105 18 1890
;
run;
/*Task- increase 1000 rs per year for each account and
find total amount for every customer age at 55 */

/*please write other than this */

/*Chat gpt code */

data accounts;
input accno age amount;
cards;
101 23 2000
102 32 3000
103 21 1300
104 38 2100
105 18 1890
;
run;

data accounts_updated;
set accounts;
years_to_55 = 55 - age;
total_amount_at_55 = amount + (years_to_55 * 1000);
run;

proc print data=accounts_updated;
var accno age amount years_to_55 total_amount_at_55;
run;

3 REPLIES 3
Super User

## Re: find the attached code below and write code to find solution dynamically not chatgpt code pleas

Missing details:

You request (I think)"Task- increase 1000 rs per year for each account and
find total amount for every customer age at 55 ".

Increase what? There is no variable named RS so I don't know what to increase.

Increase per year? What year? How many years? There is no date information at all in your data so do not have any clue what a start or end of the time period to "increase" anything would be.

"Customer age at 55": You currently show no age 55 customers. So nothing to total. This might be involved with  your not well defined "increase" so try defining that better.

You should also state exactly what is wrong with that chatgpt solution. It looks reasonable for one possible interpretation of your request. I can think of several others but need more details.

If you know what the the desired total is for the small example data then you should show us what that might be as a way of testing whether any guesses as to the actual requirements are close.

Diamond | Level 26

## Better subject line needed.

Could you please help us all? Please go back to your original post and change the Subject line so that it briefly describes the problem you are trying to solve, and doesn't talk about how you need help on writing code.

--
Paige Miller
PROC Star

## Re: find the attached code below and write code to find solution dynamically not chatgpt code pleas

You want total rupees at age 55, starting with AMOUNT at age AGE.

What's wrong with the chatgpt code?

Edit: and what do you mean by finding the solution "dynamically"?  I see nothing static about the chatgpt solution.  (Perhaps you mean that the age limit 55 is to be made into a paramenter).

--------------------------
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

--------------------------
Discussion stats
• 3 replies
• 470 views
• 1 like
• 4 in conversation