BookmarkSubscribeRSS Feed
paddyb
Quartz | Level 8

Hi

 

I am trying to merge datasets to see if there are missmatch in labels,There are multiple studies and would like to see labels for variable like in dataset C.First I tried to join 2 datasets and its overwritting label .Any suggestion please?

merge.png

3 REPLIES 3
Reeza
Super User
Give them different variable names. You can rename it in the MERGE statement if that's what you're using.
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

use a rename statement for the labels column in table b so that when you merge the data you have a column for the labels from a and b 

 

something like this


data have;
 set have(rename=(label=have_label));
run;

ballardw
Super User

Something like this may help. DICTIONARY.COLUMNS is a special data source that SAS stores all the information describing all of the variables in all data sets in currently assigned libraries.

This assumes that all of your sets are in the same library which I indicated by 'YOURLIB' the name needs to be in uppercase and in quotes. Memname also should be in uppercase. If you have a large number of similar names you may be able to use the LIKE predicate with wildcards.

 

I couldn't tell what library you are using, I suspect that you actually want memname to be the name of other data sets like ADAE instead of the "sets" that you show in the picture.

 

The proc tabulate output will have the name of the variable as the left-most row label grouping all the values of label. The columns will be the data set name and a 1 will appear under dataset name that matches the variable name and label combination.

 

proc sql;
   create table labels as
   select memname, name, label
   from dictionary.columns
   where libname='YOURLIB' and
      memname in ('DATASETA' 'DATASETB' 'DATASETC' 'DATASETD')
   ;
quit;

proc tabulate data=labels;
  class memname name label;
  table name=''*label='',
        memname
        /misstext=' '
   ;
run;

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
  • 3 replies
  • 1494 views
  • 0 likes
  • 4 in conversation