BookmarkSubscribeRSS Feed
Justin9
Obsidian | Level 7

Hi,

 

I am using proc sql below but was wondering if someone could tell me what the best way is to exclude some variables in the "B" dataset from being selected when the table is being created (as I only want the "DATE" and "PLACE" variables from dataset A to be shown in the created table)? As my "B" dataset has over 100 variables, I would like to keep 98 of them when I left join in onto the "A" dataset, but not select the "DATE" and "PLACE" variables (i.e. not select B.DATE and B.PLACE).

 

proc sql;
     create table Final_Information as
     select A.*
           ,B.*   /*How to include all B dataset variables, except "B.DATE" and "B.PLACE"? */
      from AC.TEST as a
      left join INITIAL_DATA as b
            on a.RECORD_NUMBER=b.RECORD_NUMBER
      ;
quit;

 

 

 

1 REPLY 1
Angel_Larrion
SAS Employee

You can exclude those variables from the dataset in the from clause:

proc sql;
     create table Final_Information as
     select A.*
           ,B.*   
      from AC.TEST as a
      left join INITIAL_DATA(drop=DATE PLACE) as b
            on a.RECORD_NUMBER=b.RECORD_NUMBER
      ;
quit;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 701 views
  • 2 likes
  • 2 in conversation