Do you want the maximum value in the new column, or the value of a specific observation?
Maximum:
proc sql;
create table want as
select
  have.*,
  max(profit) as X
from have;
quit;
Specific:
proc sql;
create table want as
select
  have.*,
  (select profit from have where company = 'paytm') as X
from have;
quit;
					
				
			
			
				
			
			
			
				
			
			
			
			
			
		You want a new observation with company = 'Total' and profit = sum of profits?
This is mostly needed for reporting, and the SAS procedures for that can handle it, so there's no need to add an observation.
But just to show you how it's done:
data want;
set have end=eof;
retain sum_profit 0;
output;
sum_profit + profit;
if eof
then do;
  company = 'Total';
  profit = sum_profit;
  output;
end;
drop sum_profit;
run;
					
				
			
			
				
			
			
			
			
			
			
			
		Do you want the maximum value in the new column, or the value of a specific observation?
Maximum:
proc sql;
create table want as
select
  have.*,
  max(profit) as X
from have;
quit;
Specific:
proc sql;
create table want as
select
  have.*,
  (select profit from have where company = 'paytm') as X
from have;
quit;
					
				
			
			
				
			
			
			
			
			
			
			
		It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.