Hi,
I have a csv file:
01/02/2009,146,394 |
02/02/2009,278,791 |
03/02/2009,224,637 |
04/02/2009,275,725 |
05/02/2009,276,1Â 101 |
06/02/2009,247,1Â 103 |
07/02/2009,154,412 |
08/02/2009,192,609 |
09/02/2009,308,992 |
10/02/2009,333,1Â 287 |
11/02/2009,342,1Â 250 |
12/02/2009,375,1Â 975 |
13/02/2009,275,1Â 019 |
14/02/2009,120,487 |
15/02/2009,133,567 |
16/02/2009,210,770 |
I remove  with the command 'compress', no problem.
But to remove the space, there is a problem, the command 'compress', does nothing.
Why?
My goal is not to change the csv file but to transform eg:
1Â 056 -- compress --> 1 056 --> compress --> 1056
data toto;
infile 'C:\.........................\sessionsetpagesvues.csv' dlm=',' firstobs=8 truncover;
input Index_des_jours :ddmmyy. Sessions :numx. x3 $;
x4=compress(x3,'Â ','a');
x5=compress(x4,'','s');
Pages_vues= input(x5, numx.);
run;
proc print data=toto(obs=350);run;
proc contents data=toto;run;
x5=compress(x4,'','s');
This command does not work why?
Thank you for your help.
It's not a space '20'x it just looks like one. It is non-breaking space 'A0'x.
It's not a space '20'x it just looks like one. It is non-breaking space 'A0'x.
I'm not sure why that doesn't work, as that was my first answer.
Anyway, you can use Perl regular expressions like so:
data test;
variable = "1 045";
rid = prxparse('s/\s*//');
call prxchange(rid, -1, variable);
drop rid;
run;
Just to add, the compress function has various modifiers you can apply to it which should simplfy your code:
x4=compress(x3,,'kd');
Note I put no characters in the second paramter, the 'KD' or keep decimals, does everything needed here. For example:
data a; abcd="1Â 101"; def=compress(abcd,,"kd"); run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.