BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
supersasnewbie
Calcite | Level 5

Hello,

I have a table of codes that I'm trying to select a subset from. However, I can't seem to be able to pull this correctly. Any help will be greatly appreciated!

The table, named tbl_CODES, only has one field, named PROC_CD. However, there is a mix of codes, such as: A1000, A1001, B1000, B2000, 00005, 00003. How do I create a table based on tbl_CODES where PROC_CDs begin with the character "A" only?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

It sounds like you want the value of a specific variable, not "variables beginning with 'A' ".

 

The =: operator is a "begins with.

So an example with a data set you should have available:

proc print data=sashelp.class noobs;
   where name=:'A';
run;

Prints just the records where the Name variable starts with 'A'.

Or use in a data set option when indicating which data set you are using.

proc print data=sashelp.class(where=( name=:'A')) noobs;
;
run;

View solution in original post

2 REPLIES 2
Quentin
Super User

Please show the code you have tried, and also any errors you see in the log.  If you have no errors but your code is not working, please describe how the results you are getting differ from what you want.

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
ballardw
Super User

It sounds like you want the value of a specific variable, not "variables beginning with 'A' ".

 

The =: operator is a "begins with.

So an example with a data set you should have available:

proc print data=sashelp.class noobs;
   where name=:'A';
run;

Prints just the records where the Name variable starts with 'A'.

Or use in a data set option when indicating which data set you are using.

proc print data=sashelp.class(where=( name=:'A')) noobs;
;
run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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