SAS 9.3 变量数据无效 [英] SAS 9.3 Invalid data for variable

查看:38
本文介绍了SAS 9.3 变量数据无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 SAS 中的程序无法正常运行时遇到问题.我从我的文件中获取数据的方式有问题,它弄乱了里面的所有东西.这是我的代码混乱的部分:

I'm having a problem with my program in SAS running properly. There's something wrong with the way I'm acquiring data from my file and it's messing up everything inside. Here is the portion of my code messing up:

    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;

这是我正在处理的数据:

And here is the data I'm working with:

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 数据.我很感激人们能给我的任何方向.

Every time I run it, it tells me, "NOTE: Invalid data for Number" for each line. It makes all my data off (such as the date values and whatnot). I understand that my calculated variables will not work because they're dependent on the Number data that isn't being acquired properly. I'd appreciate any direction people can give me.

推荐答案

去掉所有冒号 ( : ).
然后在数字的 4 后面添加一个点 ( . ) 以明确它是一个信息.
这应该可以解决问题.

Get rid of all the colons ( : ).
Then add a dot ( . ) after the 4 of number to make clear it is an informat.
That should do the trick.

这篇关于SAS 9.3 变量数据无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆