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

Hi Community,

 

I work with SAS on z/OS, and I was wondering if anyone had a recommendation on setting up a scan for non-printable EBCDIC characters from an incoming dataset.

 

Thanks for any input.

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

Like this?

 

data T;
  length STR1 STR2 STR3 $256;
  do I=0 to 255;
    STR1=cats(STR1,byte(I));
  end;
  STR2=prxchange('s/[^[:graph:]]//',-1,STR1);   
  STR3=prxchange("s/[^ a-i j-r ~-z {-I }-R S-Z 0-9 \x4A-\x4E \x5A-\x5F \x6A-\x6F \x79-\x7F &\/\-\\]//",-1,STR1);   
  putlog STR1= / STR2= / STR3=;
run;

The posix character class can't deal with EBCDIC it seems, but spelling out the characters to keep works.

 

 

STR1= € ‚ƒ„
…† -‡ˆ‰Š‹ŒŽ‘’""•–—˜™š›œž âäàáãåçñ¢.<(+|&éêëèíîïìß!$*);^-/ÂÄÀÁÃÅÇѦ,%_>?øÉÊËÈÍÎÏÌ`:#@'="Øabcdefg

hi«»ðýþ±°jklmnopqrªºæ¸Æ¤µ~stuvwxyz¡¿Ð[Þ®¬£¥·©§¶¼½¾Ý¨¯]´×{ABCDEFGHI­ôöòóõ}JKLMNOPQR¹ûüùúÿ\÷STUVWXYZ²ÔÖÒÓÕ0123456789³ÛÜÙÚŸ

 

STR2=âäàáãåçñ¢.<(+|&éêëèíîïìß!$*);^-/ÂÄÀÁÃÅÇѦ,%_>?øÉÊËÈÍÎÏÌ`:#@'="Øabcdefghi«»ðýþ±°jklmnopqrªºæ¸Æ¤µ~stuvwxyz¡¿Ð[Þ®¬£¥·©§¶¼½¾Ý¨¯]´×{ABCDEFGH

Iôöòóõ}JKLMNOPQR¹ûüùúÿ\÷STUVWXYZ²ÔÖÒÓÕ0123456789³ÛÜÙÚ

 

STR3=¢.<(+&!$*);^-/¦,%_>?`:#@'="abcdefghijklmnopqr~stuvwxyz{ABCDEFGHI}JKLMNOPQR\STUVWXYZ0123456789

 

 

 

 

 

 

View solution in original post

9 REPLIES 9
ChrisNZ
Tourmaline | Level 20

Like this?

 

data T;
  length STR1 STR2 STR3 $256;
  do I=0 to 255;
    STR1=cats(STR1,byte(I));
  end;
  STR2=prxchange('s/[^[:graph:]]//',-1,STR1);   
  STR3=prxchange("s/[^ a-i j-r ~-z {-I }-R S-Z 0-9 \x4A-\x4E \x5A-\x5F \x6A-\x6F \x79-\x7F &\/\-\\]//",-1,STR1);   
  putlog STR1= / STR2= / STR3=;
run;

The posix character class can't deal with EBCDIC it seems, but spelling out the characters to keep works.

 

 

STR1= € ‚ƒ„
…† -‡ˆ‰Š‹ŒŽ‘’""•–—˜™š›œž âäàáãåçñ¢.<(+|&éêëèíîïìß!$*);^-/ÂÄÀÁÃÅÇѦ,%_>?øÉÊËÈÍÎÏÌ`:#@'="Øabcdefg

hi«»ðýþ±°jklmnopqrªºæ¸Æ¤µ~stuvwxyz¡¿Ð[Þ®¬£¥·©§¶¼½¾Ý¨¯]´×{ABCDEFGHI­ôöòóõ}JKLMNOPQR¹ûüùúÿ\÷STUVWXYZ²ÔÖÒÓÕ0123456789³ÛÜÙÚŸ

 

STR2=âäàáãåçñ¢.<(+|&éêëèíîïìß!$*);^-/ÂÄÀÁÃÅÇѦ,%_>?øÉÊËÈÍÎÏÌ`:#@'="Øabcdefghi«»ðýþ±°jklmnopqrªºæ¸Æ¤µ~stuvwxyz¡¿Ð[Þ®¬£¥·©§¶¼½¾Ý¨¯]´×{ABCDEFGH

Iôöòóõ}JKLMNOPQR¹ûüùúÿ\÷STUVWXYZ²ÔÖÒÓÕ0123456789³ÛÜÙÚ

 

STR3=¢.<(+&!$*);^-/¦,%_>?`:#@'="abcdefghijklmnopqr~stuvwxyz{ABCDEFGHI}JKLMNOPQR\STUVWXYZ0123456789

 

 

 

 

 

 

SASuser28
Fluorite | Level 6

That's great. I was hoping someone would reply back using a PRX function. 

data_null__
Jade | Level 19

@ChrisNZ you're missing one character from STR1 do you know why?  Which one?

 

This is a good example for using SUBSTR on the LEFT or better still COLLATE to gen the entire string

 

substr(str1,i+1,1)=byte(I);

collate(0,256);
SASuser28
Fluorite | Level 6

Thanks data_null_!

data_null__
Jade | Level 19

If you want to remove everything that is non-printable COMPRESS would be easy enough.

 

compress(str1,,'kw')

 

ChrisNZ
Tourmaline | Level 20

@data_null__ Thanks for your input.

 

1- It doesnt matter a space is missing from the example output.That's not the point.
I must use collate more though, Thanks for the reminder.

 

2- STR4=compress(STR1,,'kw');  gives the same resut as the posix expression in STR2. Not good.

 

 

data_null__
Jade | Level 19

@ChrisNZ wrote:

@data_null__ Thanks for your input.

 

1- It doesnt matter a space is missing from the example output.That's not the point.
I must use collate more though, Thanks for the reminder.

 

2- STR4=compress(STR1,,'kw');  gives the same resut as the posix expression in STR2. Not good.

 

 


1.  I didn't say it was the point I just ask if you which and why.

2.  I guess it depends on your definition of printable.  Seems like your are defining printable characters as characters on the keyboard "type-able" and I could understand where that might be useful but I don't think that's what is being asked.

ChrisNZ
Tourmaline | Level 20

@data_null__ EBCDIC has 95 printable characters and that's it. Not the 190 that compress() lets through. If not, I want to learn more. 🙂

ChrisNZ
Tourmaline | Level 20

I would call this a defect actually. Why on earth does the compress function on Z/OS use the posix character list?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 9 replies
  • 2018 views
  • 4 likes
  • 3 in conversation