BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
IgorR
Quartz | Level 8

Hi,

This is the code, which excepted to return numbers from 1 to 40 in "Cohort" column,

but from some reason returns numbers to 41 and duplicate the last result in "FV" column.

What do I miss?

 

%let Grossid = 1;
%let DmeiNihul = 0.014;
%let NetPremium = 94;

Data A;

Target = 0;
Rate   = (1+0)/(1+&Grossid*&DmeiNihul)-1;

do Period = 1 to 4;
	do Cohort = 1 to 40;
		If Period = 1 Then
     		do;
           	If Target = 0 Then
                FV = 0;
           	Else FV = Finance('PV',rate,Cohort,&NetPremium*(-1),0,1)*(1+rate)**cohort;
     		end;
		Else FV = Finance('PV',rate,Cohort,&NetPremium*(-1),0,1)*(1+rate)**cohort;
		output;
	end;
	output;
end;

run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Remove the last output; statement

--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Remove the last output; statement

--
Paige Miller
sbxkoenk
SAS Super FREQ

Hello,

 

If you get rid of the last output; statement (run; line minus 2).

Does that give you what you want?
At least there's no cohort 41 then.

 

Koen

IgorR
Quartz | Level 8

Thank you!

It works.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1359 views
  • 4 likes
  • 3 in conversation