sql - 如何为每个新列值连续添加常量值?
问题描述
我的数据如下所示:
number letter
1 a
1 b
1 c
2 d
2 e
3 f
3 g
3 h
3 i
我想在“数字”字段中的每个新值处插入 3 个新行(x、y、z),使其看起来像这样:
number letter
1 a
1 b
1 c
1 x
1 y
1 z
2 d
2 e
2 x
2 y
2 z
3 f
3 g
3 h
3 i
3 x
3 y
3 z
帮助?
解决方案
在 SAS 中,您可以在数据步骤中添加一些 OUTPUT 语句。
data want ;
set have ;
by number;
output;
if last.number then do letter='x','y','z';
output;
end;
run;
推荐阅读
- javascript - Mongoose 按数组最后一个对象中的属性分组
- mysql - SQL 查找获取没有特定状态的项目
- python - 将字典列表写入 Pandas Dataframe 的同一行
- angular - 如何导航到产品构建 index.html 页面中的组件?
- python - 将python套接字连接到portmap.io
- javascript - 如何区分两种 http 错误情况:CORS 阻塞与服务器已关闭
- mysql - 如何在 MySQL 中获得精确的十进制值而不进行四舍五入
- javascript - 如何从 Angular 视图中的字符串翻译 unicode?
- ipython - 无法在 Spyder 的 IPython 控制台中查看已执行的单元代码
- c# - 以编程方式更改单元格值时触发的 DataGridView 事件是什么?(不是由用户编辑)