我想在 SAS 的表中添加 auto_increment 列 [英] I want to add auto_increment column in a table in SAS
本文介绍了我想在 SAS 的表中添加 auto_increment 列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 SAS 的表中添加一个 auto_Increment 列.以下代码添加一列但不增加值.提前致谢.
I want to add a auto_Increment column in a table in SAS.Following code add's a column but not increment the value. Thanks In Advance.
proc sql;
alter table pmt.W_cur_qtr_recoveries
add ID integer;
quit;
推荐答案
在数据步骤中使用 _N_
自动变量,例如:
Use the _N_
automatic variable in a data step like:
DATA TEMPLIB.my_dataset (label="my dataset with auto increment variables");
SET TEMPREP.my_dataset;
sas_incr_num = _N_; * add an auto increment 'sas_incr_num' variable;
sas_incr_cat = cat("AB.",cats(repeat("0",5-ceil(log10(sas_incr_num+1))),sas_incr_num),".YZ"); * auto increment the sas_incr_num variable and add 5 leading zeros and concatenate strings on either end;
LABEL
sas_incr_num="auto number each row"
sas_incr_cat="auto number each row, leading zeros, and add strings along for fun"
...
这篇关于我想在 SAS 的表中添加 auto_increment 列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文