我在 SAS 中的程序正常运行时遇到问题。我从文件中获取数据的方式出了点问题,它弄乱了里面的一切。这是我的代码混乱的部分:
data Stocks;
infile 'location of file.txt';
input @1 Stock : $4.
@5 PurDate : mmddyy10.
@15 PurPrice : dollar6.1
@21 Number : 4
@25 SellDate : mmddyy10.
@35 SellPrice : dollar6.1;
TotalPur = Number * PurPrice;
TotalSell = Number * SellPrice;
Profit = TotalSell - TotalPur;
run;
proc print data=Stocks;
var Stock PurDate PurPrice Number SellDate SellPrice TotalPur TotalSell Profit;
run;
这是我正在使用的数据:
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/2006 $12.7
BBY 02/15/2005 $45.2 10009/09/2006 $56.8
数据说明如下:
Stock --> Starting Column: 1, Length: 4, Type: Char.
PurDate --> Starting Column: 5, Length: 10, Type: mm/dd/yyyy.
PurPrice --> Starting Column: 15, Length: 6, Type: Dollar Signs and Commas.
Number --> Starting Column: 21, Length: 4, Type: Num.
SellDate --> Starting Column: 25, Length: 10, Type: mm/dd/yyyy.
SellPrice --> Starting Column: 35, Length: 6, Type: Dollar Signs and Commas.
每次我运行它时,它都会告诉我,“注意:数字的无效数据”对于每一行。它会关闭我的所有数据(例如日期值等)。我了解我的计算变量将不起作用,因为它们依赖于未正确获取的 Number 数据。我会很感激人们能给我的任何方向。