BookmarkSubscribeRSS Feed
axelpuri1
Calcite | Level 5
I need help writing a formula for a compute block for variable Unweighted_Scenario_1
 
Unweighted_Scenario_1 = Scenario_Param_1 * Unweighted_Amount
 
There are 4 levels for Scenario_Param_1
 
the first one 1.1 (110%) is for Level 1 including all sub levels of level 1 
the second one 1.2 (120%) is for Level 2A
the third and fourth is for individual line items (sample1 & sample 2 ) for level 2B
 
the question marks (???) in the SAS code block is where the formula needs to go 
 
data Report_3a;	
	set work.report_3(keep=Category Level Sub_Level Description Weightage Unweighted_Amount Weighted_Amount Scenario_Param_1);
	
run;

proc print data= Report3a;
	title 'LCR_NSFR_Sample_Programming_Report3';
run;

proc report data= work.report_3a out=work.report_3b;
	column Category Level Sub_Level Description Weightage Unweighted_Amount Weighted_Amount Scenario_Param_1 Unweighted_Scenario_1 Weighted_Amount_Scenario_1;
	define category / order;
	define Level / order;
	define Sub_Level / order;
	define Description / display;
	define Weightage / analysis;
	define Unweighted_Amount / analysis;
	define Weighted_Amount / analysis;
	define Scenario_Param_1 / analysis;
	define Unweighted_Scenario_1 / computed f=dollar10.3;
	define Weighted_Amount_Scenario_1 / computed f=dollar10.3;
	
	
	
	compute Unweighted_Scenario_1;
		Unweighted_Scenario_1=  ???
	endcomp;
	
	rbreak after / summarize;
	break after sub_level / summarize;
	
	
run;

proc print data=work.report1_b;
run;
datalines;
Asset . . 12941.75 . . .
Asset Level 1 . . 5859 1.10 . .
Asset Level 1 Level 1 A . . 5859 . . .
Asset Level 1 Level 1 A Sample1 1 2779 2779 . 3,056.90 3,056.90
Asset Level 1 Level 1 A Sample2 0.4 1356 542.4 . 1,491.60 596.64
Asset Level 1 Level 1 A Sample3 0.8 2424 1939.2 . 2,666.40 2,133.12
Asset Level 1 Level 1 A Sample4 0.2 2992 598.4 . 3,291.20 658.24
Asset Level 2 . . 7082.75 . . 0.00
Asset Level2 Level 2 A . . 5803.25 1.20 . 0.00
Asset Level2 Level 2 A Sample1 0.9 1371 1233.9 . 1,645.20 1,480.68
Asset Level2 Level 2 A Sample2 0.75 2465 1848.75 . 2,958.00 2,218.50
Asset Level2 Level 2 A Sample3 0.45 2648 1191.6 . 3,177.60 1,429.92
Asset Level2 Level 2 A Sample4 1 1529 1529 . 1,834.80 1,834.80
Asset Level2 Level 2 B . . 1279.5 . . 0.0
Asset Level2 Level 2 B Sample1 0.5 1208 604 1.10 1,328.80 664.40
Asset Level2 Level 2 B Sample2 0.5 1351 675.5 1.00 1,351.00 675.50
;;;;
 
report_3.png
3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

Having data (in the form of a program) and matching output would help us simulate your need.

axelpuri1
Calcite | Level 5

Hi Chris 

 

Thanks for your message 

 

I referred to this post How to create a data step version of your data AKA... - SAS Support Communities to create the datalines that you see in my post 

 

Could you kindly delineate how exactly to put forth the data in the form of a program , that would be great ! 

ChrisNZ
Tourmaline | Level 20

Data lines are not very useful without a description of the variables.

Read again the page you linked to.

Post a working program to create the data. Also, use the appropriate icon to post code.

 

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
  • 387 views
  • 0 likes
  • 2 in conversation