BookmarkSubscribeRSS Feed
aminkarimid
Lapis Lazuli | Level 10

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.

2 REPLIES 2
kiranv_
Rhodochrosite | Level 12

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;
Reeza
Super User
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;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 522 views
  • 0 likes
  • 3 in conversation