English 中文(简体)
变数被定义为特性和数字。
原标题:Variable has been defined as both character and numeric
  • 时间:2015-09-03 11:07:10
  •  标签:
  • sas

围绕上述错误开展工作:

变数被定义为特性和数字。

我的摘录是,在《联合国系统会计准则》中印制了一张表格,另一张摘要摘录了,每天有数百个缩略表,有些地方有一个或两个在一栏中具有数值。

我目前的步骤就是这样做:

DATA ALL;
   SET Library.XYZ:;
RUN;

上校看上任何贴在<代码>XYZdate9.上的标签;

But when I run the code I get the error on Column A. Is there a way to either force the column into character or just drop it completely when I merge the tables?

问题回答

Manual sollution

假设你有问题 页: 1

DATA ALL;
SET Library.XYZaaa 
    Library.XYZbbb (rename (problemColumn = problemChar))
    Library.XYZccc ;

如今,对于XYZbbb的意见(行文),问题研究不会有价值(销售价值为.),而是存在问题。 慈善机构将具有你们所需要的价值的特性。

if problemColumn eq . then problemColumn = input(problemChar, best12.);
RUN;

您可能需要用适合您数据的内容取代输入格式<代码>best12.。

Automated sollution

撰写一份表格,列出贵数据集,更名为需要数据集:

PROC SQL;
    select  Library. || memName ||
           case when type =  char  then   (rename (problemColumn = problemChar))  
                else    end
    into :setsToRead separated by    
    from sasHelp.vcolumns
    where libName eq  LIBRARY  and memName like  XYZ%  and name =  problemColumn ;
quit;

现在使用已形成的宏观变量

Data ALL;
    Set &setsToRead.;

页: 1

理想的情况是,你应确定来源,以便所有栏目都与总计划界定的类型相同。 选择只是放弃这个领域,这似乎使你能够利用欧佩克方案。

这里有一些准则可以找到问题一栏,以便你能够人工确定。

*Code to isolate the variable/tables that may be the issue;
proc sql;
create table variable_types as
select libname, memname, upper(name) as name, type
from sashelp.vcolumn
where libname= WORK  and upper(memname) like  CLASS% 
order by name, type;

create table variable_mismatch as
select * 
from variable_types
where name in (select name from variable_types group by name having min(type) ne max(type));
quit;

在这里,如果你只是想放弃需要纳入宏观结构的变量,那么就有一些准则。

*Create sample datasets;
data class;
set sashelp.class;
run;

data class2;
set sashelp.class(rename=age=age_num);

age=put(age_num, 2.);
run;

*Append via data step - generates error;
data want;
set class class2;
run;

*Append via proc append;
proc append base=class data=class2 force;
run;

制图学信息有助于确定图书馆各表具有多种类型的各种变量。

这取决于你如何处理这个问题。 要么把所有物品转换为特性,要么对微观数据集进行更正,以确保有一致的类型。 强有力的解决办法将计算一份ATTRIB声明,该声明确保了所有共同变量的长度,足以防止拖拉。

例:

data one;
  xxx =  a ;
  a =  a ;
data two;
  XXX = 1;
  b = b ;
data three;
  xXx =  ccc ;
  a= a ;
  b= C ;
run;

proc sql;
  create table variables_with_differing_types as
  select libname, memname, name, type
  from dictionary.columns
  where libname =  WORK 
  group by libname, upcase(name)
  having min(type) ne max(type)
  ;

“entergram

您不妨在数据流中增加主控表(即元数据表),具体列出每一变量的类型,并用预克来实施微观数据集必须符合主表的政策。





相关问题
SAS stack overflow: PROC SQL reading dictionary.columns

I have a program in which I am reading dictionary.columns. There is a big program with lot of code before and after the program segment in which I read dictionary.column. The program used to work ...

SAS using encrypted (PWENCODE) in EMAILPW= option

My code works fine using plain text code, but fails when I use an encrypted password filename File email emailsys = VIM emailid= "&pa_usr" emailpw= "{sasenc}39AAD23E148A9555508AC84447181DFF" ; ...

How do I change the label in a data step header?

In SAS you can do. data a(rename=(a=b) ); a = 1; run; to rename a variable in the data step data statement (or data step header as I call it). What s the syntax to change the label? I tried ...

What s the easiest way to use SQLite with SAS?

I want to investigate how to access SQLite DB from SAS. What s the easiest way of doing this? Is there a SAS product that we can license to do that? I don t want to use ODBC drivers as that seems to ...

Computing Compounded Return in SAS

I have a dataset of date(monthly), person and return(monthly). I need to calculate the compounded monthly return of the dataset from April Year t to March Year t+1 for each person. For example, ...

Exchange Server and SAS 9.1.3/9.2

has anyone successfully interacted with a microsoft exchange server in SAS 9.1.3 or 9.2? i know it can be done with SAS Ent. Guide 4.x, but i m not interested in that route if regular SAS can do it.

Logging SAS scripts

I ve been developing a lot of Java, PHP and Python. All of which offer great logging packages (Log4J, Log or logging respectively). This is a great help when debugging applications. Especially if the ...

热门标签