Date: Wed, 14 May 2003 10:40:30 -0700 Reply-To: Wei Sender: "SAS(r) Discussion" From: Wei Organization: http://groups.google.com/ Subject: Re: suppressing quotes in export; breaking apart variables Content-Type: text/plain; charset=ISO-8859-1 For your 2) var1a = scan(var1, 1, ":"); var1b = scan(var1, 2, ":"); for your 3) do while (index(line, "<") > 0); first = index(line, "<"); len = Index(line, ">") - first + 1; word = substr(line, first, len); line = tranwrd(line, trim(word), ","); end; headmind@mindhead.com (simian) wrote in message news:<84843a13.0305132346.a2b5a9c@posting.google.com>... > Hello all, > > I have a question about a kluge, and maybe some of you know a solution > that will enable me to avoid the kluge entirely. > > 1) I'm trying to export a table as a colon-delimited file. SAS > defaults to putting double quotes around a value that contains a colon > already. How do I suppress this behavior? Here's my current script: > > data _null_; > set EE.EE end=EFIEOD; > file 'd:\ee_out.txt' > delimiter=':' DSD DROPOVER lrecl=32767; > format var1 $500. ; > format var2 best12. ; > format var3$40. ; > if _n_ = 1 then do; > put 'var2' ':' > 'var1a' ':' > 'var1b' > ; end; > do; > EFIOUT + 1; > put var2 @; > put var1 \$; > ; end; > run; > > 2) The point of doing the above is that I want to use the colons > embedded in the values of var1 to break out var1 into two separate > fields, var1a and var1b. I had planned to do this by exporting the > file as above, and then re-importing it as a colon-delimited file, but > the double quotes foiled me. > > Is there an easier way to create new variables out of existing ones > based on an internal delimiter in the data step without this > import/export madness? For example, creating out of a var1 value of > 'alpaca:llama' new variables, var1a = 'alpaca' and var1b = 'llama'? > > 3) on a related note, how I got to 'alpaca:llama' in the first place > was by having something like > "alpacallama' in a long character > variable. I knew what the tended to look like so I killed it > like so: > > var1 = tranwrd(compbl(trim(var1)),"",""); > > What I'd rather do is simply replace anything in < >'s with a > delimiter (without knowing whether the contents of the < > are > identically "junk" or not), and then delimit my file by those new > delimiters. > > Any thoughts? > > Thank you! > > VJ > headmind@mindhead.com 

Back to: Top of message | Previous page | Main SAS-L page