BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
MILKYLOVE
Calcite | Level 5

Hello,

 

I have a program that creates a csv file. When I open this csv file in ultra edit, I get a hex value of '00' in certain columns. (see image below), that is '.....'

I want to change these to blanks (hex value 20). How can I make this conversion only on these specific hex values?

 

MILKYLOVE_0-1680264266307.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

%DS2CSV is just going to write the values in the dataset.

 

To change one character to another you can use the TRANSLATE() function.

 

SO if the binary zeros are in the variable XXX you could use a data step like this to create a new dataset with the zeros replaced with spaces.

data want;
  set have;
  xxx=translate(xxx,' ','00'x);
run;

If you have such bytes in multiple variables then use an array:

data want;
  set have;
  array __c _character_;
  do over __c;
    __c=translate(__c,' ','00'x);
  end;
run;

Once you have a dataset without the binary zeros then you can write a CSV file that will not have binary zeros.

View solution in original post

7 REPLIES 7
Kurt_Bremser
Super User

We can only be of help if we see the code which is creating this file. If display formats are not part of the export code, also show the format assigned to that particular variable in the dataset.

 

BTW, anybody with excess time can reconstruct your blacked-out strings from the hex codes 😉

MILKYLOVE
Calcite | Level 5

Hello,

 

Thank you for your reply. Please find the code below:

 

%ds2csv

(data = work.SOLUTION2, runmode = b, csvfile= &RacineRun.&RacineIV./fichiers/solution_2.csv, sepchar = 3B, colhead=y, formats=y, labels=n );

MILKYLOVE
Calcite | Level 5
Also the format is character
MILKYLOVE
Calcite | Level 5
Also the format is character
Tom
Super User Tom
Super User

%DS2CSV is just going to write the values in the dataset.

 

To change one character to another you can use the TRANSLATE() function.

 

SO if the binary zeros are in the variable XXX you could use a data step like this to create a new dataset with the zeros replaced with spaces.

data want;
  set have;
  xxx=translate(xxx,' ','00'x);
run;

If you have such bytes in multiple variables then use an array:

data want;
  set have;
  array __c _character_;
  do over __c;
    __c=translate(__c,' ','00'x);
  end;
run;

Once you have a dataset without the binary zeros then you can write a CSV file that will not have binary zeros.

MILKYLOVE
Calcite | Level 5

Thank you so much!! 

 

This worked

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 7 replies
  • 2105 views
  • 0 likes
  • 3 in conversation