在 SAS 中添加一条记录? [英] Adding a single record in SAS?

查看:20
本文介绍了在 SAS 中添加一条记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了如何使用 proc append 将表附加到基础.我想知道是否有一种更简单的方法(不需要创建临时保存表)来添加一条记录?我找到的所有解决方案都需要几行,我想知道是否有更简单的东西,比如我缺少的删除"命令?

I've found how to append a table to a base with proc append. I'm wondering if there is a simpler way (that doesn't require creating a temporary holding table) that adds a single record? All solutions I find require several lines, I'm wondering if there's something more straightforward like the "delete" command that I'm missing?

推荐答案

您可以使用带有 modify 语句的数据步骤来插入额外的行.任何其他类型的数据步骤都涉及创建临时文件并替换原始文件,这在您对大型数据集进行小幅更改时是不可取的.

You can use a data step with a modify statement to insert additional rows. Any other sort of data step involves creating a temporary file and replacing the original, which is undesirable when you're making a small change to a large dataset.

data class;
    set sashelp.class;
run;

data class;
    modify class;
    Name = 'ZZZ';
    output;
    stop;
run;

这会将数据集的第一行读入 PDV,然后将更新后的值追加到 Name 中,使所有其他变量的值与第一行相同.

This reads in the first row of the dataset to the PDV and then appends it with an updated value of Name, leaving the values of all the other variables as they were in the first row.

注意如果没有 stop 语句,这将导致无限循环,因为 SAS 将无限期地交替添加和追加记录,永远不会接近数据集的末尾.

N.B. without the stop statement, this will cause an infinite loop, as SAS will alternately add and append records indefinitely, never getting any closer to the end of the dataset.

这篇关于在 SAS 中添加一条记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆