我有以下代码:
visitnum = put(visitn,visitnumber.);
指向
proc format;
value visitnumber
'Screening Assessment' = 1
'Treatment Visit - Day 1' = 2
'Treatment Visit - Day 7' = 3
'Treatment Visit - Day 14/15' = 4
'Follow-Up Visit - Day 28' = 5
run;
但是,当我输出'visitnum'变量时,它给出' treat '作为匹配列的输出。
如果这是字符到数字,则需要使用信息而不是格式。
proc format;
invalue visitnumber
'Screening Assessment' = 1
'Treatment Visit - Day 1' = 2
'Treatment Visit - Day 7' = 3
'Treatment Visit - Day 14/15' = 4
'Follow-Up Visit - Day 28' = 5
;
run;
的例子:
data foo;
length visitn $27.;
do visitn = 'Screening Assessment'
, 'Treatment Visit - Day 1'
, 'Treatment Visit - Day 7'
, 'Treatment Visit - Day 14/15'
, 'Follow-Up Visit - Day 28'
;
visitnum = input(visitn, visitnumber.);
output;
end;
run;
输出:visitn visitnum
Screening Assessment 1
Treatment Visit - Day 1 2
Treatment Visit - Day 7 3
Treatment Visit - Day 14/15 4
Follow-Up Visit - Day 28 5
您对结果的描述似乎表明输入字符串与格式所知道的任何值都不匹配。在这种情况下,PUT()函数将只回显输入。如果PUT()函数调用中使用的格式规范的宽度小于输入字符串的长度,则可能发生截断。如果目标变量VISITNUM被定义为比PUT()函数返回的字符串短,则可能发生截断。
因此,要么是VISITN的值与FORMAT所知道的任何值不匹配,要么是没有找到该格式。