Hello Everybody
I have a problem, I have a DB for fifteen thousand lines. And this table has a specific column, which I call "CPF".
Well, in this CPF I have this type of sequence of numbers like this: "086.602.38373" "838.399.200.13"
I want to remove these points, so: "08660238373" "83839920013"
My table name: Gus If someone can write the entire code by pulling my CPF column from my Gus table.
Best regards,
You cannot have values like "086.602.38373" "838.399.200.13" in a numeric variable. So your source variable must be a character string. You can remove the periods from a character variable using the COMPRESS() function. If you want to convert the string without periods into a number using the INPUT() function. Note that SAS stores all numbers as floating point so the maximum number of digits you have have is 16 (really 15).
data gus;
infile CPF $20. ;
cards;
086.602.38373
838.399.200.13
;
data want;
set gus;
CPF_number = input(compress(CPF,'.'),32.);
format CPF_number 16.;
run;
This is a character variable, correct?
You cannot have values like "086.602.38373" "838.399.200.13" in a numeric variable. So your source variable must be a character string. You can remove the periods from a character variable using the COMPRESS() function. If you want to convert the string without periods into a number using the INPUT() function. Note that SAS stores all numbers as floating point so the maximum number of digits you have have is 16 (really 15).
data gus;
infile CPF $20. ;
cards;
086.602.38373
838.399.200.13
;
data want;
set gus;
CPF_number = input(compress(CPF,'.'),32.);
format CPF_number 16.;
run;
Its work!!
Thank you, so much!!
CVF New_cvf
Even without the periods you will probably still want to keep that variable as a string. I doubt that you are going to take the MEAN or do other arithmetic on those values.
If the other table has the values stored as a number then using a number would be easier to match. With character strings you have to worry about leading zeros (or leading spaces). But that assumes the string of digits are short enough that they resulting integer can be stored exactly into the floating point numbers that SAS uses.
Actually,
I found this:
ERROR 23-2: Invalid option name $20..
@GUST1 wrote:
Actually,
I found this:
ERROR 23-2: Invalid option name $20..
Show more of the log to see what you did. You must have done something really creative to get SAS to think you had put the $20. into a place where it was expecting options.
INPUT not INFILE
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.