BookmarkSubscribeRSS Feed
Gick
Pyrite | Level 9

Hello, I have several sas tables (T1, T2, T3, etc.) I want to concatenate its different tables.

I do the data step correctly with the set instruction. But I get empty lines. On the documentation, it states to see the types of certain variables and to order the variables. I've done it but I still get empty observations.
I cannot send an extract of the bases because I cannot find the examples that I know how to create to reflect the problem. Thank you for understanding.

 

Can anyone give me some hints ?

 

THANKS.
Gick

7 REPLIES 7
LinusH
Tourmaline | Level 20
Same name but different data type, that won't work properly.
One way managing things is to create view(s) to align the data sets so they look the same (variable names, data types, lenghts).
Data never sleeps
Gick
Pyrite | Level 9
For certain variables, I have missing data even though all my tables are filled.
Patrick
Opal | Level 21

@Gick Put yourself into our shoes and try to imagine if you really could say what you're doing with the depth and breath of information you've provided so far. Thank you for your understanding.

ballardw
Super User

I'm going to repeat something in a bit more detail that you aren't paying attention to:

 

If variables of the same name are of different data types then one or more sets of the values will be missing in the output because a variable can only be ONE TYPE in a data set, either character or numeric. If you try to put an "ABC" into a variable that is numeric it will always fail, result in a missing value and generally the log will tell you that you did something wrong.

In this case I would expect an error such as this shows from attempting to combine two sets with the same named variable of different types:

196  data one;
197    x=123;
198  run;

NOTE: The data set WORK.ONE has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


199
200  data two;
201    x='ABC';
202  run;

NOTE: The data set WORK.TWO has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


203
204  data combined;
205    set one
206        two
207    ;
ERROR: Variable x has been defined as both character and numeric.
208  run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.COMBINED may be incomplete.  When this step was
         stopped there were 0 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


Depending on what you have been doing, exact code and data sets you may be looking at an earlier data set as a result. But that is why we have asked you to show the LOG of your attempt, including the code and all the notes, messages, warnings and/or errors like above.

Reeza
Super User
How were these datasets created? Did you create them? If so, the best solution is to back up a step and avoid the issue in the first place.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 7 replies
  • 1186 views
  • 0 likes
  • 6 in conversation