BookmarkSubscribeRSS Feed
debdippal
Calcite | Level 5

Suppose we have two data sets namely data_set_1 & data_set_2. Now some variables are present in data_set_2 which are not belonging to data_set_1. Now our aim is to remove those variables from data_set_2 which are not belonging to data_set_1.

Now I am giving the description of the data sets.

Data_set_1

Name          val_1     val_2

forum           10            15

quiz                 5            14

assign            14             8

     

Data_set_2

class      user forum   dq   assign quiz

1              1            5         2 4           1

1              2            6         3        2          5

Some variables like class, user, dq are not belonging to data_set_1. So we have to drop this variable from data_set_2. One more thing we should keep in mind that variables in data_set_1 are in row format where as variables in data_set_2 are in column format. We do not want to use any transpose statement. 

1 REPLY 1
RichardinOz
Quartz | Level 8

Proc SQL Noprint ;

     select name into :keeplist separated by ' '

     ;

Quit ;

Data Data_Set_2a ;

     Set Data_set_2 ;

     Keep &keeplist ;

Run ;

Richard

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