Hello, I'm trying to do simple calculations but I'm new and SAS is not intuitive to me.
 
Suppose I have this table.
 
data money;
infile datalines delimiter=",";
input name $ return $ invested;
datalines;
Joe,10,100
Bob,7,50
Mary,80,1000
;
 
Which creates this
 
 
/* name | return | invested */
/* _________________________ */
/* Joe  | 10     | 100 */
/* Bob  | 7      | 50 */
/* Mary | 80     | 50 */
1. I need to make sure columns 'return' and 'invested' are numeric. When I run the code above, 'return' column ends up being a CHAR column and I don't know why.
 
2. Now I want to create a new column and calculate the share of the total return they each got. In this case, the sum of 'return' =97. This is the result I want.
 
/* name     | return | invested | share_of_return */
/* ____________________________________________ */
/* Joe      |  10   | 100       | 10.30% */
/* Bob      |   7   | 50        | 7.22% */
/* Mary     | 80    | 50        | 82.47% */
 
3. Next I want to find their ROI. Which is (return-investment) / investment * 100. This is the result I am looking for
/* Find ROI */
/* name | return | invested | share_of_return | ROI */
/* ___________________________________________________ */
/* Joe  | 10     | 100      | 10.30%          | -90% */
/* Bob  | 7      | 50       | 7.22%           | -86% */
/* Mary | 80     | 50       | 82.47%          | 60% */
I appreciate your explanations and guidance in advanced. This is for a work project and we just switched over to SAS