BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
amar8580
Calcite | Level 5

hi all

i am using the following code

PROC SQL;
CREATE TABLE PI AS
SELECT A.* FROM WORK.VRPT_PI_DAILY A
UNION
SELECT B.* FROM WORK.VRPT_PI_WEEKLY_FINAL B
UNION
SELECT C.* FROM WORK.VRPT_PI_MONTHLY C
UNION
SELECT D.* FROM WORK.VRPT_PI_QTR D;
QUIT;

 

now strange thing is happening....some of the values are missing for various numeric columns when i open the pi table

eg: revenue

but if i open the tables individually, i do see values in all 4 tables.

1 ACCEPTED SOLUTION

Accepted Solutions
collinelliot
Barite | Level 11

In the image you attached, I see "...SER_CAR" before "TCA" in the top data and "..W_BPS" before "TCA" in the lower data. To me that suggests these columns are not aligned identically. 

 

What if you use "UNION CORR"?

View solution in original post

6 REPLIES 6
collinelliot
Barite | Level 11

Are all your columns that you want to concatenate in the same position, same name? Have you tried "UNION CORR"?

 

Without seeing your data, it's hard to diagnose what's going on, but SAS is almost certainly doing what it's supposed to do.

amar8580
Calcite | Level 5

yes they are the same columns and position is correct.

see attached screenshot

when i look at the weekly dataset, it shows value for TCA column

the moment i merge it, i see data for daily, monthly and quartely but for weekly TCA cell, the value is missing

 


union_table.PNG
collinelliot
Barite | Level 11

In the image you attached, I see "...SER_CAR" before "TCA" in the top data and "..W_BPS" before "TCA" in the lower data. To me that suggests these columns are not aligned identically. 

 

What if you use "UNION CORR"?

amar8580
Calcite | Level 5

thanks a lot

my weekly dataset was missing columns

now its all good

 

collinelliot
Barite | Level 11

Happy to help.

lkeyes
Obsidian | Level 7

I noticed that in your screenshot that there is a column to the left of [TCA] in the VRPT_PI_WEEKLY_FINAL table that is something like [...W_BPS]; but in the constructed SQL table, it is [...SER_CAR]

 

Could that be an issue? Maybe i missed something about the order of the columns. But i see that you've selected (*) on all of your tables. 

 

That would be my best guess??

Try a subset of specific columns, just to see if you get the appropriate records in there. And yeah, definitely use UNION CORRseems to clear things up for me. 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 6 replies
  • 3110 views
  • 2 likes
  • 3 in conversation