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;
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.
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.
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).
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.