BookmarkSubscribeRSS Feed
ElisabettaC
Calcite | Level 5

Hello,
I need to append two tables loaded in SAS:
- STORIC_TABLE of about 1.2 TB and 50 columns
- TAB1 of about 30 GB and 51 columns (one column more than the STORIC_TABLE)
I would like to know which is the most optimized code to append the TAB1 to the STORIC_TABLE. 

Obviously, due to the presence of one more field, the STORIC_TABLE will have missing values corresponding the new TAB1 field
thanks
ElisabettaC

10 REPLIES 10
tarheel13
Rhodochrosite | Level 12
You could just concatenate them.

Data stacked;
Set tab1 storic_table;
Run;
ElisabettaC
Calcite | Level 5
Hi lrackley,
thanks for your quick reply.
I tried this solution but it's not very efficient because it rewrites the first table which is too big (about 1.2 tb).
Any other suggestions without rewriting tables?
tarheel13
Rhodochrosite | Level 12

Could try proc SQL outer union or proc append. This paper shows all the way to combine data vertically and you could read more about the efficiency as well as see examples. 

https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2019/3161-2019.pdf 

ElisabettaC
Calcite | Level 5
The problem is that proc sql with create table statement and proc append don't work with SAS Viya CAS tables.
Suggestions on how to use OUTER UNION CORR in PROC FEDSQL?
tarheel13
Rhodochrosite | Level 12
Haha I actually don’t know what CAS is. I don’t use Viya! I found this documentation. It looks like union is supported in FedSQL.
https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=fedsqlref&docsetTarget=n1...
ElisabettaC
Calcite | Level 5

Unfortunately, the outer union corr option doesn't work with proc fedsql, as shown in the image below:

ElisabettaC_0-1610977542722.png

 

tarheel13
Rhodochrosite | Level 12

The link I sent you said "corresponding". did you try it with that? 

ElisabettaC
Calcite | Level 5

"Union corresponding" doesn't fail but doesn't return the expected result!
With union corresponding  it appends only the fields that match (50 fields) and doesn't create the new field.

The expected table must have 51 columns.

tarheel13
Rhodochrosite | Level 12

Why do you have to use corresponding? What if you just try "outer union"? Do you get 51 then? 

ElisabettaC
Calcite | Level 5

No, I get a syntax error (same error even with outer union corr)

ElisabettaC_0-1610980993754.png

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 1900 views
  • 0 likes
  • 2 in conversation