SAS PRO C SQL UNION ALL - минимизирует длину столбца - PullRequest
1 голос
/ 06 января 2020

У меня есть 8 таблиц, каждая из которых содержит одинаковый порядок и количество столбцов, в то время как один указанный столбец c с именем ATTRIBUTE содержит разные данные длиной от 4 до 25. Когда я использую PRO C SQL и UNION ВСЕХ таблиц длина данных столбца ATTRIBUTE в минимизированном виде (до 4 цифр). Как мне решить эту проблему, т.е. сохранить полную длину данных?

1 Ответ

0 голосов
/ 06 января 2020

Пример, для @ Lee

data have1;
  attrib name length=$10 format=$10.;
  name = "Anton Short";
run;

data have2;
  attrib name length=$50 format=$50.;
  name = "Pippy Longstocking of Stoyville";
run;

* column attributes such as format, informat and label of the selected columns
* in the result set are 'inherited' on a first found first kept order, dependent on 
* the SQL join plan (i.e. the order of the tables as coded for the query);

proc sql;
  create table want as
  select name from have1 union
  select name from have2
  ;

proc contents data=want varnum;
run;

Формат закорочен, чем Length , любой вывод более длинных значений будет обрезан на уровне данных.

enter image description here

* attributes of columns can be reset,
* (cleared so as to be dealt with in default manners),
* without rewriting the entire data set;

proc datasets nolist lib=work;
  modify want;
  attrib name format=;  * format= removes the format of a variable;
run;

proc contents data=want varnum;
run;

enter image description here

...