LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2011, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 20 May 2011 19:43:20 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: CSV TagSet question
Comments: To:
In-Reply-To:  <COL118-W24DE6FD7B9B5885A2A5491F1710@phx.gbl>
Content-Type: text/plain; charset="Windows-1252"

Michelle, I can do it the way I want via a data step which I wrote up... I was looking for an easier way together than the data _null_ step. In short I have a very ugly csv file , where a record can be scattered over N number of lines, which uses single qoutes around the text field values, inside of which many contain commas and single qoutes, and the program the guy who extracted the data used upcases all the variable names in the header without qoutes around them and places a trailing comma delimiter at the end of each line. So the thought process went like this, write a program that will clean up the raw csv files, then another program that reads them in, and finally a third program that takes the data sets and writes them back out in the same format as the cleaned up files and then use the dif command in Unix to comapre the two. I have steps 1 and 2 done, step three is done but with the csv tagset so darn close to what I need with possibly a few tweeks it could be there. Hmmm this might be a question for Eric the tagset guy at SAS to answer for me... hmmm can;t remember if he owes me a favor still or not.

Toby Dunn

If you get thrown from a horse, you have to get up and get back on, unless you landed on a cactus; then you have to roll around and scream in pain. “Any idiot can face a crisis—it’s day to day living that wears you out” ~ Anton Chekhov

From: To:; Subject: RE: CSV TagSet question Date: Fri, 20 May 2011 14:31:54 -0500

Another MZ gave a similar solution on list....

What you have

"Obs","Name","Sex","Age","Height","Weight" "1","Alfred","M",14,69.0,112.5 "2","Alice","F",13,56.5,84.0 "3","Barbara","F",13,65.3,98.0 "4","Carol","F",14,62.8,102.5 "5","Henry","M",14,63.5,102.5 "6","James","M",12,57.3,83.0 "7","Jane","F",12,59.8,84.5 "8","Janet","F",15,62.5,112.5 "9","Jeffrey","M",13,62.5,84.0 "10","John","M",12,59.0,99.5 "11","Joyce","F",11,51.3,50.5 "12","Judy","F",14,64.3,90.0 "13","Louise","F",12,56.3,77.0 "14","Mary","F",15,66.5,112.0 "15","Philip","M",16,72.0,150.0 "16","Robert","M",12,64.8,128.0 "17","Ronald","M",15,67.0,133.0 "18","Thomas","M",11,57.5,85.0 "19","William","M",15,66.5,112.0 What you want NAME,SEX,AGE,HEIGHT,WEIGHT 'Alfred','M',14,69.0,112.5, 'Alice','F',13,56.5,84.0, . . . 'William','M',15,66.5,112.0,

What I got Name , Sex , Age , Height , Weight 'Alfred','M',14,69.0,112.5 'Alice','F',13,56.5,84.0 'Barbara','F',13,65.3,98.0 'Carol','F',14,62.8,102.5 'Henry','M',14,63.5,102.5 'James','M',12,57.3,83.0 'Jane','F',12,59.8,84.5 'Janet','F',15,62.5,112.5 'Jeffrey','M',13,62.5,84.0 'John','M',12,59.0,99.5 'Joyce','F',11,51.3,50.5 'Judy','F',14,64.3,90.0 'Louise','F',12,56.3,77.0 'Mary','F',15,66.5,112.0 'Philip','M',16,72.0,150.0 'Robert','M',12,64.8,128.0 'Ronald','M',15,67.0,133.0 'Thomas','M',11,57.5,85.0 'William','M',15,66.5,112.0

ods listing close; ODS CSV FILE="temp.csv"; PROC PRINT DATA=SASHELP.CLASS noobs; RUN; ODS CSV CLOSE; ods listing;

data _null_; infile 'temp.csv'; file 'temp.csv'; input; if _n_ = 1 then _infile_ = translate(_infile_,' ','"'); else _infile_ = translate(_infile_,"'",'"'); put _infile_; run; Where is this file going? I usually use ods to html with xls it's very easy to work with. I don't use csv, just because of the quoting issues. Michelle Z.

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