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

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
1 ACCEPTED SOLUTION

Accepted Solutions
ManitobaMoose
Quartz | Level 8

I see. Cannondale was spelled Canondale in the second set. Everything works now. Thanks.

View solution in original post

2 REPLIES 2
ManitobaMoose
Quartz | Level 8

I'm sorry, the bike manuf is Trek and Canondale, not the Model. The code is written for this. Thanks.

ManitobaMoose
Quartz | Level 8

I see. Cannondale was spelled Canondale in the second set. Everything works now. Thanks.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 682 views
  • 0 likes
  • 1 in conversation