BookmarkSubscribeRSS Feed
psychopedia
Calcite | Level 5

   As question mentioned, I have several tables with product IDs variables from different time, a lot of which are in common. However, some of each contains ID that the others do not contain.

   I want to combine them vertically based on their time, but only take the common variables in all the tables. Is there a simple step I can do that instead of checking for missing data in the new table everytime I combine them? Thank you!

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hello @psychopedia,

 

Do you mean something like this?

/* Create test data */

data have1;
array x year a b c d e (2011 10:14);
run;

data have2;
array x year b c d e f g (2012 20:25);
run;

data have3;
array x year c d e f g h (2013 30:35);
run;

/* Combine tables vertically, restricted to common variables */

proc sql;
create table want as
select * from have1 union all corr
select * from have2 union all corr
select * from have3;
quit;

proc print data=want noobs;
run;

You may want to check the sort order in dataset WANT and possibly add an ORDER BY clause if you're not satisfied.

psychopedia
Calcite | Level 5

Thank you! This is what I m looking for. Really appreciate it.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 490 views
  • 0 likes
  • 2 in conversation