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 | ||||||||
date | var01 | var02 | date | var01 | var02 | date | var01 | var02 | ||
1 | 123 | asd | 4 | 456 | asd | 7 | 789 | asd | ||
2 | 234 | sdf | 5 | 567 | sdf | 8 | 890 | sdf | ||
3 | 345 | dfg | 6 | 678 | dfg | 9 | 321 | dfg |
And I want to create below tables:
file01 | file02 | |||||
date | var01 | var02 | date | var01 | var02 | |
1 | 123 | asd | 6 | 678 | dfg | |
2 | 234 | sdf | 7 | 789 | asd | |
3 | 345 | dfg | 8 | 890 | sdf | |
4 | 456 | asd | 9 | 321 | dfg | |
5 | 567 | sdf |
I have variables which their attributs are showed below:
TRD_EVENT_DT | Num | 8 | DATE9. | DATE9. | TRD_EVENT_DT |
TRD_EVENT_TM | Char | 8 | $8. | $8. | TRD_EVENT_TM |
TRD_PR | Char | 5 | $5. | $5. | TRD_PR |
TRD_STCK_CD | Char | 5 | $5. | $5. | TRD_STCK_CD |
TRD_TUROVR | Char | 9 | $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.
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;
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.