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