Help using Base SAS procedures

Delimiter

Reply
Regular Contributor
Posts: 229

Delimiter

i have dataset with delimiter in beetween the observations i want all the delimiters should be replaced with comma.

data c;
input id$ sal$;
if id ='%' then id=',';
cards;
kool-% ra/,'l
nani(^/ mo-'
run;
proc print;
run;


output should be like this
kool,, ra,,,,
nani,,, mo,,
Super Contributor
Super Contributor
Posts: 3,174

Re: Delimiter

SAS PROC IMPORT and EXPORT may be suitable for your requirements.

As well, you may find that the DATA step approach will work, as you have described in your forum post. For a DATA step approach, you can use the DLM= option on both the INFILE (also include the DSD parameter) and the FILE statements, along with the INPUT and PUT statements to read in and out your file.

The SAS support website http://support.sas.com/ contains product documentation and supplemental technical user community (SUGI / SGF) papers with examples on this topic. I used the site's SEARCH facility and found one technote referenced below for the inputting perspective. Have a look at the SAS Base Language Reference: Dictionary for using the FILE statement for the output perspective.

Scott Barry
SBBWorks, Inc.


http://support.sas.com/techsup/technote/ts673.html
Regular Contributor
Posts: 229

Re: Delimiter

can any one help me inthis
Respected Advisor
Posts: 4,173

Re: Delimiter

Use the function 'translate()' for your ID variable.
If you don't know all possible special characters then a more generic solution would be possible using Regular Expressions - but it's also more difficult to code...
HTH
Patrick
Ask a Question
Discussion stats
  • 3 replies
  • 141 views
  • 0 likes
  • 3 in conversation