SAS 9.3变量的数据无效

Red*_*ght 1 sas

我的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;
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的数据:

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
Run Code Online (Sandbox Code Playgroud)

数据描述如下:

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.
Run Code Online (Sandbox Code Playgroud)

每次我运行它,它告诉我,"注意:每行的数字无效".它会关闭所有数据(例如日期值和诸如此类的东西).我知道我的计算变量不起作用,因为它们依赖于未正确获取的Number数据.我很欣赏人们可以给我的方向.

mvh*_*weg 5

摆脱所有的冒号(:).
然后在数字4之后添加一个点(.)以表明它是一个信息.
这应该够了吧.

  • 确实.为了更好地解答答案:列表输入需要冒号,而不是列输入.不要混淆两个!List主要用于分隔输入(即空格,逗号等列表); 应该用列读取固定列(`@ 1 varname informat.). (4认同)