Variable |
Description |
Starting Column |
Length |
Type |
Stock |
Stock symbol |
1 |
4 |
Char |
PurDate |
Purchase date |
5 |
10 |
mm/dd/yyyy |
PurPrice |
Purchase price |
15 |
6 |
Dollar signs and commas |
Number |
Number of shares |
21 |
4 |
Num |
SellDate |
Selling date |
25 |
10 |
mm/dd/yyyy |
SellPrice |
Selling price |
35 |
6 |
Dollar signs and commas |
A listing of the data file is:
stockprices.txt
IBM 5/21/2006 $80.0 10007/20/2006 $88.5 CSCO04/05/2005 $17.5 20009/21/2005 $23.6
MOT 03/01/2004 $14.7 50010/10/2006 $19.9
XMSR04/15/2006 $28.4 20004/15/2007 $12.7
BBY 02/15/2005 $45.2 10009/09/2006 $56.8
Create a SAS data set (call it Stocks) by reading the data from this file. Use formatted input.
Compute several new variables as follows:
Variable |
Description |
Computation |
TotalPur |
Total purchase price |
Number times PurPrice |
TotalSell |
Total selling price |
Number times SellPrice |
Profit |
Profit |
TotalSell minus TotalPur |
Print out the contents of this data set using PROC PRINT.
| Program name: stocks. sas in c:\books\learning | Purpose: Read in raw data on stock prices and compute values -k * . *a; data portfolio; infile 1 c : \books\learning\stocks . txt ' ; input Symbol $ Price Number; Value = Number*Price ; run; title "Listing of Portfolio"; proc print data=portf olio noobs; run; *b; title "Means and Sums of Portfolio Variables"; proc means data=portf olio n mean sum maxdec=0; var Price Number; run;
Get Answers For Free
Most questions answered within 1 hours.