data tourrevenue;
input Country $ 1-11 LandCost Vendor $ customer;
cards;
France 575 Express 10
Spain 510 World 12
Brazil 540 World 6
Japan 720 Express 10
Greece 698 Express 20
Venezuela 425 World 8
Italy 468 Express 9
Russia 924 World 6
Switzerland 734 World 20
Ireland 558 Express 9
;
Run;
Proc sort data = tourrevenue
by vendor;
run;
How do I get to this from the data set about???
| Country | LandCost | Vendor | Customer | Percentages | New_Landcost |
| France | 575 | Express | 10 | 0.527272727 | 303.18 |
| Japan | 720 | Express | 10 | 0.527272727 | 379.64 |
| Greece | 698 | Express | 20 | 0.527272727 | 368.04 |
| Italy | 468 | Express | 9 | 0.527272727 | 246.76 |
| Ireland | 558 | Express | 9 | 0.527272727 | 294.22 |
| Spain | 510 | World | 12 | 0.472727273 | 241.09 |
| Brazil | 540 | World | 6 | 0.472727273 | 255.27 |
| Venezuela | 425 | World | 8 | 0.472727273 | 200.91 |
| Russia | 924 | World | 6 | 0.472727273 | 436.80 |
| Switzerland | 734 | World | 20 | 0.472727273 | 346.98 |
| This is how the percentage was arrived at | ||
| Vendor | Customer | Percentages |
| Express | 58 | 0.52727 |
| World | 52 | 0.47273 |
| Total | 110 | 1 |
data have; input Country $ 1-11 LandCost Vendor $ customer; cards; France 575 Express 10 Spain 510 World 12 Brazil 540 World 6 Japan 720 Express 10 Greece 698 Express 20 Venezuela 425 World 8 Italy 468 Express 9 Russia 924 World 6 Switzerland 734 World 20 Ireland 558 Express 9 ; Run; Proc sort data = have; by vendor; run; proc sql; create table want as select *,(select sum(customer) from have where Vendor=a.Vendor)/(select sum(customer) from have) as per format=8.5,calculated per*landcost as new from have as a; quit;
Ksharp
data have; input Country $ 1-11 LandCost Vendor $ customer; cards; France 575 Express 10 Spain 510 World 12 Brazil 540 World 6 Japan 720 Express 10 Greece 698 Express 20 Venezuela 425 World 8 Italy 468 Express 9 Russia 924 World 6 Switzerland 734 World 20 Ireland 558 Express 9 ; Run; Proc sort data = have; by vendor; run; proc sql; create table want as select *,(select sum(customer) from have where Vendor=a.Vendor)/(select sum(customer) from have) as per format=8.5,calculated per*landcost as new from have as a; quit;
Ksharp
Try below code : Will get the same result as required.
data
tourrevenue;
input Country :$ 1-11 LandCost Vendor $ customer;
cards;
France 575 Express 10
Spain 510 World 12
Brazil 540 World 6
Japan 720 Express 10
Greece 698 Express 20
Venezuela 425 World 8
Italy 468 Express 9
Russia 924 World 6
Switzerland 734 World 20
Ireland 558 Express 9
; Run;
Proc sort data = tourrevenue ;by vendor; run;
data Percen;
input Vendor $ Customer Percentages;
cards;
Express 58 0.52727
World 52 0.47273
; run;
proc sort data = percen; by vendor; run;
data merge_both;
merge tourrevenue(in=aa) percen(In=bb);
by Vendor;
if aa = 1;
New_Landcost = LandCost*Percentages; run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.