Hi,
I merged two sets by the variable model, and created a new variable called Newtotal. The bike model "Trek" works perfectly, but Canondale produces missing data, even though there is no missing data in either of the two sets. Can someone take a look and see what I am doing wrong? Thanks.
Here is the first set:
libname Learn '/folders/myfolders/Learn' ;
data learn.bicycles;
input Country & $25.
Model & $14.
Manuf : $10.
Units : 5.
UnitCost : comma8.;
TotalSales = (Units * UnitCost) / 1000;
format UnitCost TotalSales dollar10.;
label TotalSales = "Sales in Thousands"
Manuf = "Manufacturer";
datalines;
USA Road Bike Trek 5000 $2,200
USA Road Bike Cannondale 2000 $2,100
USA Mountain Bike Trek 6000 $1,200
USA Mountain Bike Cannondale 4000 $2,700
USA Hybrid Trek 4500 $650
France Road Bike Trek 3400 $2,500
France Road Bike Cannondale 900 $3,700
France Mountain Bike Trek 5600 $1,300
France Mountain Bike Cannondale 800 $1,899
France Hybrid Trek 1100 $540
United Kingdom Road Bike Trek 2444 $2,100
United Kingdom Road Bike Cannondale 1200 $2,123
United Kingdom Hybrid Trek 800 $490
United Kingdom Hybrid Cannondale 500 $880
United Kingdom Mountain Bike Trek 1211 $1,121
Italy Hybrid Trek 700 $690
Italy Road Bike Trek 4500 $2,890
Italy Mountain Bike Trek 3400 $1,877
;Second Set:
Data review.markup ; input manuf : $10. markup ; Datalines ; Canondale 1.05 Trek 1.07 ;
My Code:
proc sort data=learn.bicycles ; by Manuf ; run ; proc sort data=review.markup ; by manuf ; run ; Data review.Markup_Price ; Merge learn.bicycles review.markup ; by Manuf ; NewTotal = Unitcost*Markup ; run ; Proc print data=review.markup_price noobs ; Var manuf unitcost markup Newtotal ; run ;
Finally, the results:
Manuf UnitCost markup NewTotal Cannondale $880 . . Cannondale $1,899 . . Cannondale $2,700 . . Cannondale $3,700 . . Cannondale $2,123 . . Cannondale $2,100 . . Canondale . 1.05 . Trek $690 1.07 738.30 Trek $490 1.07 524.30 Trek $540 1.07 577.80 Trek $650 1.07 695.50 Trek $1,121 1.07 1199.47 Trek $1,877 1.07 2008.39 Trek $1,300 1.07 1391.00 Trek $1,200 1.07 1284.00 Trek $2,100 1.07 2247.00 Trek $2,500 1.07 2675.00 Trek $2,890 1.07 3092.30 Trek $2,200 1.07 2354.00
I see. Cannondale was spelled Canondale in the second set. Everything works now. Thanks.
I'm sorry, the bike manuf is Trek and Canondale, not the Model. The code is written for this. Thanks.
I see. Cannondale was spelled Canondale in the second set. Everything works now. Thanks.
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!
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.