SAS:从多个数据集创建多个文件 [英] SAS: creating multiples files from multiple data sets

查看:736
本文介绍了SAS:从多个数据集创建多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有24个数据集,以相同的方式结构。我的意思是相同的列标题(时间,日期,价格,股票符号),数据集结构等。我不想追加所有24个文件,因为一个数据集是大的处理。我命名所有我的数据集,名称为file1 file2 file3 file4 ....最多为file24。

I have 24 datasets that are structured in the same way. By that I mean the same column headers (time, date, price, stock symbol), data set structure etc. I don't wish to append all 24 files since one data set is to big to handle. I named all my data sets with the name "file1 file2 file3 file4....up to file24".

我想做的是以下操作:


  1. 示例一次更改所有24个文件中的日期格式;

  1. For example change the date format in all of my 24 files at once;

可以从每个文件中提取特定的股票符号所有提取的Dell数据;

Be able to extract from each file# a specific stock symbol like 'Dell' and append all the extracted 'Dell' data;

最后,如何创建一个循环,允许我将股票代码从Dell股票符号在我的列表像'Goog'?我想这个循环做(2)所有的股票符号。

and finally, how can I create a loop that that allows me to change the stock symbol from 'Dell' to another stock symbol in my list like 'Goog'? I would like that loop to do (2) for all of my stock symbols.


推荐答案

这是解决方案的原型。我不知道你是否需要做许多符号更改。将根据请求修改代码。没有测试,它应该工作。

This is a prototype of solution. I don't know whether you need to do many symbol changes. Will modify the code upon request. Haven't tested, it should work though.

%macro test();
%do i=1 %to 24;
  data file&i;
   set file&i;
    format date [dateformat];  /*replace with the format you want */ 

proc append base=unions data=file&i(where=(stock_symbol='Dell'));

data unions;
 set unions;
  stock_symbol='Goog';

%end;
%mend;

%test(); run;

这篇关于SAS:从多个数据集创建多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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