Sas sql不尊重我的fcmp函数长度

Sas sql不尊重我的fcmp函数长度,sas,proc-sql,fcmp,Sas,Proc Sql,Fcmp,有人能解释一下如何让PROC-SQL为我的自定义函数的结果提供我在函数定义中指定的长度吗?Datastep做得很好,但是SQL给了我200个字符的默认长度 下面是演示该问题的代码: proc fcmp outlib = work.funcs.funcs ; * Note type/length specification ; function testy(istr $) $11 ; return ('bibbitybobb') ; endsub ; quit ; optio

有人能解释一下如何让PROC-SQL为我的自定义函数的结果提供我在函数定义中指定的长度吗?Datastep做得很好,但是SQL给了我200个字符的默认长度

下面是演示该问题的代码:

proc fcmp outlib = work.funcs.funcs ;
  * Note type/length specification ;
  function testy(istr $) $11 ;
    return ('bibbitybobb') ;
  endsub ;
quit ;

options cmplib = work.funcs ;

data from_dstep ;
  set sashelp.class ;
  tes = testy(name) ;
run ;

proc sql ;
  create table from_sql as
  select *
        , testy(name) as tes
  from sashelp.class
  ;

  describe table from_dstep ;
  describe table from_sql ;

quit ;
我的登录地址是:

47           describe table from_dstep ;
NOTE: SQL table WORK.FROM_DSTEP was created like:

create table WORK.FROM_DSTEP( bufsize=65536 )
  (
   Name char(8),
   Sex char(1),
   Age num,
   Height num,
   Weight num,
   tes char(11)
  );

48           describe table from_sql ;
NOTE: SQL table WORK.FROM_SQL was created like:

create table WORK.FROM_SQL( bufsize=65536 )
  (
   Name char(8),
   Sex char(1),
   Age num,
   Height num,
   Weight num,
   tes char(200)
  );
如您所见,datastep给我的'tes'变量的长度为11,而sql给我的长度为200


使用SQL时有没有办法获得长度11?

不幸的是,我不这么认为。SQL和data step在这方面的工作方式不同,其他内置函数也有一些相同的问题(例如,CAT/CATX在SQL中的默认值与data step中的不同)。我认为这与数据步骤中的编译工作方式与SQL中的解释工作方式有关。我相信我已经看到了一些具体说明这是预期行为的东西,但我现在似乎找不到它;如果你想了解更多细节,而这里没有其他人可以提供,也许可以开始跟踪,看看他们说什么

当然,您可以直接在SQL中设置:

proc sql ;
  create table from_sql as
  select *
        , testy(name) as tes length 11
  from sashelp.class
  ;
quit;