Extracting specific columns fullfulling a certain criteria from a data set in SAS

Helen

Completely new to SAS here.

I have a data set with a huge amount of variables. I would like to extract all the variables that for example contains the string "GRP" within its name, and create a new data set from these variables.

EDIT: I do not know any of the variable names, as the data set is huge.

Amir

You can first store the variables you're interested into a macro variable and then use them in a keep list. Using data set name work.have as an example to create work.want:

/* note the use of use UPPERCASE */
proc sql noprint;
  select name into :varlist separated by ' '
  from dictionary.columns
  where libname='WORK'
    and memname='HAVE'
    and upper(name) contains 'GRP'
  ;
quit;

/* keep only required variables */
data want;
  set have(keep=&varlist);
run;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Extracting specific columns from a data frame

From Dev

Extracting Shapes that meet a certain criteria from an Image

From Dev

Extracting Shapes that meet a certain criteria from an Image

From Dev

Extracting Specific Columns from a DataTable

From Dev

Extracting Specific Columns from a DataTable

From Dev

Extracting a specific type columns and specific named columns from a data frame-R

From Dev

Remove text from excel columns with certain criteria

From Dev

Extracting specific information from data

From Dev

Extracting data with a certain pattern from a .txt file

From Dev

BeautifulSoup How do I extract data from specific columns from HTML table. My code is extracting all the columns

From Dev

Extracting columns from data according to column names

From Dev

Extracting specific values from a pandas columns and storing it in new columns

From Dev

Extracting specific data from an RData file

From Dev

extracting specific data from a xml file

From Dev

extracting data from specific lines in a file

From Dev

Extracting specific option price data from Excels

From Dev

Deleting a specific rows and columns from a data-set using Matlab

From Dev

R - extracting data from certain date or time period from a dataframe

From Dev

R - extracting data from certain date or time period from a dataframe

From Dev

Extracting columns containing a certain name

From Dev

Extracting certain data from JSON response using JMeter

From Dev

Excel VBA Attempting to set range as columns and call data if criteria is satisfied

From Dev

Transpose data from row/column that matches certain criteria

From Dev

Create data set from macro variable SAS

From Dev

Extracting columns from a file

From Dev

Extracting columns from a file

From Dev

Trying to copy specific columns in a row to another excel sheet based on it meeting certain criteria

From Dev

fill missing columns with NA while extracting from a data.frame

From Dev

fill missing columns with NA while extracting from a data.frame

Related Related

  1. 1

    Extracting specific columns from a data frame

  2. 2

    Extracting Shapes that meet a certain criteria from an Image

  3. 3

    Extracting Shapes that meet a certain criteria from an Image

  4. 4

    Extracting Specific Columns from a DataTable

  5. 5

    Extracting Specific Columns from a DataTable

  6. 6

    Extracting a specific type columns and specific named columns from a data frame-R

  7. 7

    Remove text from excel columns with certain criteria

  8. 8

    Extracting specific information from data

  9. 9

    Extracting data with a certain pattern from a .txt file

  10. 10

    BeautifulSoup How do I extract data from specific columns from HTML table. My code is extracting all the columns

  11. 11

    Extracting columns from data according to column names

  12. 12

    Extracting specific values from a pandas columns and storing it in new columns

  13. 13

    Extracting specific data from an RData file

  14. 14

    extracting specific data from a xml file

  15. 15

    extracting data from specific lines in a file

  16. 16

    Extracting specific option price data from Excels

  17. 17

    Deleting a specific rows and columns from a data-set using Matlab

  18. 18

    R - extracting data from certain date or time period from a dataframe

  19. 19

    R - extracting data from certain date or time period from a dataframe

  20. 20

    Extracting columns containing a certain name

  21. 21

    Extracting certain data from JSON response using JMeter

  22. 22

    Excel VBA Attempting to set range as columns and call data if criteria is satisfied

  23. 23

    Transpose data from row/column that matches certain criteria

  24. 24

    Create data set from macro variable SAS

  25. 25

    Extracting columns from a file

  26. 26

    Extracting columns from a file

  27. 27

    Trying to copy specific columns in a row to another excel sheet based on it meeting certain criteria

  28. 28

    fill missing columns with NA while extracting from a data.frame

  29. 29

    fill missing columns with NA while extracting from a data.frame

HotTag

Archive