BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kalbo
Obsidian | Level 7

Hi I want to see if text values are correctly separated by a comma then space. However some values can start with SUPP__ and QNAM can contain a period (.) e.g. SUPPAE.START and QNAM.STOP.

 

For example these values are correctly arranged with a comma and single space:

SUBJID, SEQUENCE, SUPPAE.START, QNAM.STOP

SUBJID, START, SUPPCM.STOP

SUBJID, ID, QNAM.START

 

These are not correctly arranged and need to be detected:

SUBJID. SEQUENCE, SUPPAE.START. QNAM.STOP

SUBJID,START*SUPPCM.STOP

START; STOP;

START. STOP

 

I think we can use prxchange or similar prx funciton.

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

In other words, detect a space preceded by something other than comma, or a comma without following space?

if prxmatch('/[^,] |,\S/', trim(VAR));

View solution in original post

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

In other words, detect a space preceded by something other than comma, or a comma without following space?

if prxmatch('/[^,] |,\S/', trim(VAR));

kalbo
Obsidian | Level 7

Hi Chris, the string can contain any characters potentially and its possible no space was used e.g. WORD1,WORD2 or WORD1.WORD2.

ChrisNZ
Tourmaline | Level 20

These 2 examples should be treated as expected:

The first is invalid, the second is valid.

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