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

Hi,

 

In the code below min_stat, max_stat, and range are computed correctly, however, pc_stat doesn't work. 

 

data have;
	do until (last.SO);
		set have;
		by unit SO;
		min_stat = min(min_stat, distance);
		max_stat = max(max_stat, distance);
	end;

	range = max_stat - min_stat;

	pc_stat = (distance-min_stat)/range;
	do until (last.SO);
		set have;
		by unit SO;
		output;
	end;
run;

The data below shows the input, incorrect pc_stat_get and the desired pc_stat_want. The typical excel equation is:J2 =(D2-F2)/H2 where distance = D2, min_stat = F2, range = H2, and pc_stat_want = J2. Thanks.

 

unitSOdistancedatemin_statmax_statrangepc_stat_getpc_stat_want
2801111461879.68323-Jan-1861879.6869663.157783.46410
2801111465404.5224-Jan-1861879.6869663.157783.46410.45286225
2801111466928.73525-Jan-1861879.6869663.157783.46410.64868958
2801111469270.52126-Jan-1861879.6869663.157783.46410.94955639
2801111561887.20323-Jan-1861887.269652.837765.62710
2801111565411.95224-Jan-1861887.269652.837765.62710.4538911
2801111566937.29925-Jan-1861887.269652.837765.62710.65031401
2801111569260.20326-Jan-1861887.269652.837765.62710.9494404
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

The RANGE calculation is fine.

 

The PC_STAT calculation should go just before the OUTPUT statement.

 

I'm not sure the WANT example is entirely correct for PC_STAT.  Shouldn't each group have an observation where PC_STAT is 1?

View solution in original post

2 REPLIES 2
Reeza
Super User

I think your formula is correct, not sure it's in the correct location. Try moving the RANGE to your DoW portion and the PC_STAT to after the second SET statement.

Astounding
PROC Star

The RANGE calculation is fine.

 

The PC_STAT calculation should go just before the OUTPUT statement.

 

I'm not sure the WANT example is entirely correct for PC_STAT.  Shouldn't each group have an observation where PC_STAT is 1?

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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