An Idea Exchange for SAS software and services

by PROC Star
on ‎04-02-2015 02:56 PM

What benefit would this have over using substr or =:  ?

1913  data _null_ ;
1914    set sashelp.class ;
1915    if name =: 'Ro' ;
1916    put (_all_)(=) ;
1917  run ;

Name=Robert Sex=M Age=12 Height=64.8 Weight=128
Name=Ronald Sex=M Age=15 Height=67 Weight=133
NOTE: There were 19 observations read from the data set SASHELP.CLASS.

by Community Manager
on ‎04-03-2015 07:38 AM

Since this idea is for SAS Enterprise Guide, I'm assuming that you would like to see this in the Query Builder and other filter tools.  You can achieve the effect today with the "Matches pattern" option, which generates the LIKE operator.  It works like a wildcard.  Specify the text you want to match on the "beginning" and end with a %:




Does this satisfy the request? It's slightly less intuitive than "Begins with", but much more flexible.


by Occasional Contributor Ned123
on ‎04-26-2017 10:08 AM

Theres no "Matches pattern" option in my basic filter. is there any other solution to this? Im working with numerics. Thanks

by Super User
on ‎04-26-2017 10:36 AM

Not sure how you could code a "begins with" for a numeric field.  What does it even mean mathematically? 

by Occasional Contributor Ned123
on ‎04-26-2017 10:53 AM
There's no mathematic meaning. The field is just an identifier number.
Could you tell me how to convert the field to character then search for 46 and 47 in the first two spaces?

by Super User
on ‎04-26-2017 11:05 AM

Not sure how to do this using the query building tools.

You can convert a number to a string using the PUT() function. Since SAS can only uniquely stores numbers upto 15-17 digits () you could use something like

put(id,17.-l) in: ('46' '47')

Or more likely since the query building might be used PROC SQL you will need to use the SUBSTR() function instead.

substr(put(id,17.-l),1,2)  in ('46' '47')

If your IDs are all of the same magnitude, say 10 digits, then you could use arithmetic on the original value.

int(id/10**8) in (46 47)




by Occasional Contributor Ned123
on ‎04-26-2017 11:13 AM
I'm getting an error (below). Also - what is the meaning of 17.-l? I thought in a PUT statement after the comma comes the informat. So wouldn't $CHAR10. be more appropriate? (the variable has values with 10 digits.

(The error is with the comma in the PUT statement)
put(EBELN,17.-l) in: ('46' '47');
ERROR 22-322: Syntax error, expecting one of the following: [, {.

ERROR 76-322: Syntax error, statement will be ignored.
Idea Statuses
Top Liked Authors