Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove Commas 1

Status
Not open for further replies.

noway320

MIS
Aug 12, 2010
19
US
Can anyone help me? I stuck in removing commas from my sas dataset. Well, I wants to generate .csv file from my sas dataset but due to some commas are already existed in original dataset; it generates extra variable.

Thanks in advance.
 
You can remove the commas by using the compress() function or you can 'wrap' your values with quotes.
ex 1
Code:
yourvar = compress(yourvar,',');

ex 2
Code:
yourvar = '"'||trim(yourvar)||'"';

I hope that this helps you.

klaz
 
Hey klaz,
thanks for helping, but I could not able to find the whole syntax for compress statement. Actually I am very new for this SAS programming. If possible to you then can you please send me whole syntax.... like Data "data name"...

Thanks again
 
You need to know the variable name of the offending character string. In my example above I named that variable 'yourvar'. You need to place the compress() function in your datastep code.
ex
Code:
data yourdatasetname;
  set yourdssourcename;

  *** WILL REMOVE COMMAS FROM VARIABLE VALUE ***;
  yourvar = compress(yourvar,',');
run;

Klaz
 
It works, awesome!! Many many thanks for your help.
Thanks again. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top