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.

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at 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 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
  • 2 replies
  • 1231 views
  • 0 likes
  • 3 in conversation