SAS/IML:从多个矩阵创建数据集
假设我有许多 IML 矩阵。它们可以是数字或字符。我将如何利用它们创建单个 SAS 数据集?
我尝试了类似的方法
n = {1 2 3, 4 5 6}; /* 2 x 3 numeric */
c = {'a' 'b', 'c' 'd'}; /* 2 x 2 character */
dsvars = {n c};
create dat var dsvars; /* should be a 2-obs, 5-variable dataset */
append;
,但这将 n 和 c 转换为列向量并导出它们,这不是我想要的。我应该分别导出 n 和 c 并将它们合并到 DATA 步骤中吗?
Let's say I have a number of matrices in IML. They can be either numeric or character. How would I go about creating a single SAS dataset out of them?
I tried something like
n = {1 2 3, 4 5 6}; /* 2 x 3 numeric */
c = {'a' 'b', 'c' 'd'}; /* 2 x 2 character */
dsvars = {n c};
create dat var dsvars; /* should be a 2-obs, 5-variable dataset */
append;
but this turns n and c into column vectors and exports those, which is not what I want. Should I export n and c separately and merge them in a DATA step instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当 n 和 c 是向量时,您的方法有效。当它们是矩阵时,有几种方法可以做到这一点。我喜欢使用 CREATE FROM 和 APPEND FROM 语法,并将数字矩阵和字符矩阵写入单独的数据集,然后再合并:
Your approach works when n and c are vectors. When they are matrices, there are a couple of ways to do this. I like to use the CREATE FROM and APPEND FROM syntax, and write the numerical and character matrices to separate data sets that I later merge: