How to add tables till / from specific data?

Reply
Contributor
Posts: 71

How to add tables till / from specific data?

[ Edited ]

Hello everybody,

I have three tables and want to add table01 to table02 and table02 to table03. In first file, I want table01 as a whole and add table02 to it till specific time (November 19, 2013) in table02. In second file, I want table03 as a whole and add table02 to it from specific time (from November 19, 2013) in table02. Let me give you an example:

 

table01   table02   table03  
datevar01var02 datevar01var02 datevar01var02
1123asd 4456asd 7789asd
2234sdf 5567sdf 8890sdf
3345dfg 6678dfg 9321dfg

 

And I want to create below tables: 

file01   file02  
datevar01var02 datevar01var02
1123asd 6678dfg
2234sdf 7789asd
3345dfg 8890sdf
4456asd 9321dfg
5567sdf    

 

I have variables which their attributs are showed below: 

 

Alphabetic List of Variables and Attributes
# Variable      Type      Len       Format       Informat            Label
TRD_EVENT_DTNum8DATE9.DATE9.TRD_EVENT_DT
TRD_EVENT_TMChar8 $8. $8.TRD_EVENT_TM
TRD_PRChar5$5.$5.TRD_PR
TRD_STCK_CDChar$5. $5. TRD_STCK_CD 
TRD_TUROVRChar9$9.$9.TRD_TUROVR
      

 

Explanation of variables of some columns:

[TRD_EVENT_DT]: Month / Day / Year
,[TRD_EVENT_TM]: Time: hh:mm:ss
,[TRD_PR]: Stock Price
,[TRD_TUROVR]: Turnover

,[TRD_STCK_CD]: Name.

 

How can I do that?

Thanks in advance.

Regular Contributor
Posts: 227

Re: How to add tables till / from specific data?

may be something like this

proc sql;
create table file01 as 
select date, var1, var2
from table1
union all
select date, var1, var2
from table2 
where date le '19NOV2013'd;

create table file02 as 
select date, var1, var2
from table3
union all
select date, var1, var2
from table2 
where date gt '19NOV2013'd;
quit;
Grand Advisor
Posts: 17,320

Re: How to add tables till / from specific data?

data want;

set 
/*whole data set*/ data1 /*partial data sets*/ data2 (where=( datepart(date_Variable <= "01Jan2017"d)) data3 (where=( datepart(date_Variable <= "01Jan2017"d)) / *whole datasets*/ data4 ;

run;
Ask a Question
Discussion stats
  • 2 replies
  • 76 views
  • 0 likes
  • 3 in conversation