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

Hi,
iam trying to filter the column where flg not missing.
but iam still getting blank values whose records does not have flag.
i tried compress(flg) and strip(flg) options.but not wotking.
please help.

1 ACCEPTED SOLUTION

Accepted Solutions
JJP1
Pyrite | Level 9

Thanks all for your help.
Actually for flg column mainframe team is sending the null values in it.so beacuse of this SAS treated null value as value,even thought it do not have actual values.
i requested them to remove null values and send to SAS.
now it looks good.thanks

View solution in original post

14 REPLIES 14
ed_sas_member
Meteorite | Level 14

Hi @JJP1 

Coud you please share a portion of your data and the code you tried?

Did you tried then NMISS() function to filter you data for example?

Oligolas
Barite | Level 11

Hi,

 

you may have a non printable character in your flg variable, try to analyse which values it contains:

data want;
   set have;

   do i=1 to length(flg);
      rank=rank(substr(flg,i,1));
      output;
   end;
run;
proc print;run;
________________________

- Cheers -

JJP1
Pyrite | Level 9

Hi @Oligolas ,

i ran below code and i can see Y or N.how can i find out non printable character and resolve the issue please.

data want(keep=flg);
   set have

   do i=1 to length(flg);
      rank=rank(substr(flg,i,1));
      output;
   end;
run;
proc print;run;
Oligolas
Barite | Level 11

@JJP1 The number you get in the rank column stands for the ASCII code.

 

You'll know your variable contains a non-printable character whenever you get a number <= 31.

With this you'll be able to specifically aim at a sign you would like to handle.

 

________________________

- Cheers -

Ksharp
Super User
data want;
   set have;
if not anyspace(flg);
run;
JJP1
Pyrite | Level 9

Thanks @Ksharp ,

actually i need to do it using proc sql option please and iam trying below option and it says that " Variable Flg not appended because of type mismatch."would you please help

 

   proc sql;
      create table work.W5II6SX as
         select
            
               
            (anyspace(Flg )) asFlg length = 1
      from &etls_lastTable
      ;
   quit;
   
   %let SYSLAST = work.W5II6SX;
   
   %let etls_lastTable = &SYSLAST; 
JJP1
Pyrite | Level 9

Actually iam getting these values from mainframe application in the form of text file.whether the mainframe is causing the issue and sending some incorrect data please .

no data is showing just blank spaces i can see.please help

JJP1
Pyrite | Level 9

Thanks all for your help.
Actually for flg column mainframe team is sending the null values in it.so beacuse of this SAS treated null value as value,even thought it do not have actual values.
i requested them to remove null values and send to SAS.
now it looks good.thanks

Tom
Super User Tom
Super User

@JJP1 wrote:

Actually iam getting these values from mainframe application in the form of text file.whether the mainframe is causing the issue and sending some incorrect data please .

no data is showing just blank spaces i can see.please help


You need to show more details to get more help.  Are you trying to use a data step to read a text file and convert it into a SAS dataset?  Do you already have a SAS dataset?  Are you getting errors (or informative notes) in the SAS log. Show in detail what you are doing and how it does not match what you need.

Amir
PROC Star

Along the same lines as what @Oligolas has said about there potentially being non-printable characters in the flg variable, you could try something like the following code after you've filtered your data and if you get some records in the have data set then those are the ones that have non-printable characters. Your original data will have have to either be read in correctly or pre-processed to remove the non-printable characters.

 

The code removes printable characters and checks if the result is blank.

 

data want;
   set have;
   flg2 = compress(flg,,'w');
   if flg2 ne '';
run;

 

Regards,

Amir.

 

 

 

ChrisNZ
Tourmaline | Level 20

I like @Amir 's suggestion, as you end up with clean data, rather than filtering on a more complex filter without cleaning.

You could also replace non-printable characters rather than remove them as @Amir does.

data WANT;
   set HAVE;
   FLG2 = prxchange('s/\s/ /o',-1,FLG);
   if FLG2 ne '';
run;
ChrisNZ
Tourmaline | Level 20

Or:

data WANT;
   set HAVE;
   FLG2 = prxchange('s/[:^print:]/ /o',-1,FLG);
   if FLG2 ne '';
run;

to target more than white spaces.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 14 replies
  • 4834 views
  • 1 like
  • 8 in conversation