SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
juanvenegas
Fluorite | Level 6

Hi, im new to sas macros. how would I go about creating a macro to do the following: 

 

# Does the comparison table have all columns present in the base dataset?
# Does the comparison table have any columns not present in the base dataset?
# Are corresponding columns between tables of the same data type?
# Are corresponding character columns of the same length?
# Do the tables have the same number of records?

 

any help is appreciated!

3 REPLIES 3
Astounding
PROC Star

Without question, here is the right way to get started.

 

Cut out the macros.

 

Write a program that does all of this for two data sets, hard-coding the data set names.

 

Once you have working code, you can begin to think about how to change that to a macro.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Tip 1, use Base SAS.

Tip 2, use the appropriate procedure:

http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#n0c1y14wyd3u7yn1dmfcp...

Proc compare is specifically designed to do these comparisons.

Reeza
Super User
PROC COMPARE will output all of those statistics for you. And most you can capture easily into data sets.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1359 views
  • 0 likes
  • 4 in conversation