BookmarkSubscribeRSS Feed
sas_aspirant
Calcite | Level 5

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
ballardw
Super User

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.

PaigeMiller
Diamond | Level 26

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
mkeintz
PROC Star

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

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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 582 views
  • 1 like
  • 4 in conversation