【问题标题】:in SAS, is it possible to declare 2 hash tables in the same data step?在 SAS 中,是否可以在同一数据步骤中声明 2 个哈希表?
【发布时间】:2016-05-30 13:10:57
【问题描述】:

我可以像这样声明 1 个哈希表:

data DALY1;
    * set lengths ;
    length Germ $10 Category1 $50 Category2 $50 AgeGroupDALY $10 Gender $2 value 8;

    * make link to hash table ;
    if _n_=1 then do;
        declare hash h1(dataset:'modelData');
        h1.definekey ('Germ', 'Category1', 'Category2', 'AgeGroupDALY', 'Gender') ;
        h1.definedata('Value');
        h1.definedone();
        call missing(Germ, Value, Category1, Category2);
    end;
run;

但是当我这样声明 2 时:

data DALY1;
    * set lengths ;
    length Germ $10 Category1 $50 Category2 $50 AgeGroupDALY $10 Gender $2 value 8;

    * make link to hash table ;
    if _n_=1 then do;
        declare hash h1(dataset:'modelData');
        h1.definekey ('Germ', 'Category1', 'Category2', 'AgeGroupDALY', 'Gender') ;
        h1.definedata('Value');
        h1.definedone();
        call missing(Germ, Value, Category1, Category2);

        declare hash h2(dataset:'states');
        h2.definekey ('Germ') ;
        h2.definedata('stateList');
        h2.definedone();

    end;
run;

我明白了:

错误:第 194 行第 3 列的哈希对象未声明数据符号 stateList。
错误:数据步组件对象失败。在执行阶段中止。

我想知道是否可以同时声明 2 个哈希表(或更多,我需要 3 个)。
如果答案还没有,那我做错了什么?

我在任何地方都找不到这样的例子。

谢谢!

【问题讨论】:

    标签: sas hashtable datastep


    【解决方案1】:

    是的,您可以在一个 DATA STEP 中创建多个哈希表。

    参考:This Forum PaperThis SESUG paper

    您没有定义变量“stateList”。 将变量“stateList”添加到您的 LENGTH 语句中。

    【讨论】:

    • 该死,我忘记了长度:/感谢您发现这个!
    猜你喜欢
    • 2019-09-04
    • 2012-08-14
    • 2012-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-17
    • 2014-10-24
    相关资源
    最近更新 更多