f



Problem with carriage return/newline character when writing SAS database to a text file...

I had a table in Excel which included an ID (identification number),
COMMENTS, and AMOUNT column. The COMMENTS column were text notes (up
to 2000 characters) commenting on the corresponding ID. I imported
this table (via proc import) into a SAS dataset and then used the file
and put statements to write the dataset to a fixed-length text file
(i.e., for each record, the ID variabe was outputted to positions 1-4,
COMMENTS outputted to positions 6-2005, and the AMOUNT column
outputted to positions 2007-2012).

The text file, however, did not come out how I expected because some
of the text in the COMMENTS field wrapped over to the next line in the
text file (each record is supposed to appear on only one line in the
text file, not multiple lines). When I looked into the COMMENT field
in the SAS dataset I created, I noticed some tiny black, rectangular
symbols that appeared sporadically
throughout some of my records. I'm assuming those symbols represent a
carriage return/newline character (I don't know what the exact
terminology is for it)?? I noticed that wherever those symbols
appeared in the SAS dataset is where the text file broke to a new line
when the dataset was written to the text file. Is it possible to
eliminate this carriage return (or whatever it's called) symbol is
SAS? For my text file to be correct, I need to have each dataset
record appear on only one line in the text file and it appears as
though it is this carriage return which is making some of the comments
in my dataset to break to unexpectedly break to the next line in the
text file...
0
wardnine1 (2)
4/11/2008 5:41:01 PM
comp.soft-sys.sas 142828 articles. 3 followers. Post Follow

0 Replies
699 Views

Similar Articles

[PageSpeed] 14

Reply:

Similar Artilces:

Re: Problem with carriage return/newline character when writing
I am pretty sure the offending character is '0A'x. It is inserted into the comment field in EXCEL by <ALT><ENTER> key combination, to produce a new line in a cell. You can easily translate it in your SAS program to a blank using the translate function. comment = translate(comment,' ','0a'x); On Fri, Apr 11, 2008 at 12:41 PM, <wardnine@gmail.com> wrote: > I had a table in Excel which included an ID (identification number), > COMMENTS, and AMOUNT column. The COMMENTS column were text notes (up > to 2000 characters) commenting on the corresponding ID. I imported > this table (via proc import) into a SAS dataset and then used the file > and put statements to write the dataset to a fixed-length text file > (i.e., for each record, the ID variabe was outputted to positions 1-4, > COMMENTS outputted to positions 6-2005, and the AMOUNT column > outputted to positions 2007-2012). > > The text file, however, did not come out how I expected because some > of the text in the COMMENTS field wrapped over to the next line in the > text file (each record is supposed to appear on only one line in the > text file, not multiple lines). When I looked into the COMMENT field > in the SAS dataset I created, I noticed some tiny black, rectangular > symbols that appeared sporadically > throughout some of my records. I'm assuming those symbols represent a > carriage return/newline character (I don'...

Re: Problem with carriage return/newline character when writing #6
Clean the source Excel sheet. I do this on all Excel I import if they don't go in clean: find replace all "alt+0014 alt+0010" with a space, then if there are still offending characters use the excel function =clean() to make a clean copy of the column and import that. HTH ...

Re: Problem with carriage return/newline character when writing #5
I don't see the point of compbl. All that is needed is translation of 1 character '0A'x to blank. There is no '0D'x in the data, and COMPBL will compress all occurrences of 2 or more blanks to 1 which may or may not be desired. Here is the log from my test program. 1 proc import datafile='CommentsWithNewLine.xls' out=test replace; 2 run; 3 filename ft17f001 'CommentsWithNewLine.txt'; 4 5 proc print; 6 *'0a'x prints looks like a little box; 7 run; 8 9 10 data _null_; *write the file with '0a'x; 11 set test; 12 file ft17f001; 13 put comment $char50.; 14 run; NOTE: The file FT17F001 is: File Name=E:\User\dataNull\CommentsWithNewLine.txt, RECFM=V,LRECL=256 NOTE: 1 record was written to the file FT17F001. The minimum record length was 50. The maximum record length was 50. 15 16 data _null_; *view it SAS sees '0A'x as new line; 17 infile ft17f001; 18 input; 19 list; 20 run; NOTE: The infile FT17F001 is: File Name=E:\User\dataNull\CommentsWithNewLine.txt, RECFM=V,LRECL=256 RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+-- 1 This is 7 2 a comment with 14 3 new lines 27 NOTE: 3 records were read from the infile FT17F001. ...

Re: Problem with carriage return/newline character when writing #3
Comments =3D Compress( Comments , ,'KW' ) ; Toby Dunn "Don't bail. The best gold is at the bottom of barrels of crap." Randy Pausch "Be prepared. Luck is where preparation meets opportunity." Randy Pausch > Date: Fri, 11 Apr 2008 10:41:01 -0700 > From: wardnine@GMAIL.COM > Subject: Problem with carriage return/newline character when writing SAS = database to a text file... > To: SAS-L@LISTSERV.UGA.EDU > > I had a table in Excel which included an ID (identification number), > COMMENTS, and AMOUNT column. The COMMENTS column were text notes (up > to 2000 characters) commenting on the corresponding ID. I imported > this table (via proc import) into a SAS dataset and then used the file > and put statements to write the dataset to a fixed-length text file > (i.e., for each record, the ID variabe was outputted to positions 1-4, > COMMENTS outputted to positions 6-2005, and the AMOUNT column > outputted to positions 2007-2012). > > The text file, however, did not come out how I expected because some > of the text in the COMMENTS field wrapped over to the next line in the > text file (each record is supposed to appear on only one line in the > text file, not multiple lines). When I looked into the COMMENT field > in the SAS dataset I created, I noticed some tiny black, rectangular > symbols that appeared sporadically > throughout some of my records. I'm assuming those symbols rep...

Re: Problem with carriage return/newline character when writing #2
Comments = Compress( Comments , 'KW' ) ; Toby Dunn "Don't bail. The best gold is at the bottom of barrels of crap." Randy Pausch "Be prepared. Luck is where preparation meets opportunity." Randy Pausch > Date: Fri, 11 Apr 2008 10:41:01 -0700 > From: wardnine@GMAIL.COM > Subject: Problem with carriage return/newline character when writing SAS database to a text file... > To: SAS-L@LISTSERV.UGA.EDU > > I had a table in Excel which included an ID (identification number), > COMMENTS, and AMOUNT column. The COMMENTS column were text notes (up > to 2000 characters) commenting on the corresponding ID. I imported > this table (via proc import) into a SAS dataset and then used the file > and put statements to write the dataset to a fixed-length text file > (i.e., for each record, the ID variabe was outputted to positions 1-4, > COMMENTS outputted to positions 6-2005, and the AMOUNT column > outputted to positions 2007-2012). > > The text file, however, did not come out how I expected because some > of the text in the COMMENTS field wrapped over to the next line in the > text file (each record is supposed to appear on only one line in the > text file, not multiple lines). When I looked into the COMMENT field > in the SAS dataset I created, I noticed some tiny black, rectangular > symbols that appeared sporadically > throughout some of my records. I'm assuming those symbols represen...

Re: Problem with carriage return/newline character when writing #4
While a lovely suggestion and you don't have to know the values of the offending characters it produces undesirable results. It turns.... This is+a comment with+new lines in to This isa comment withnew lines Where I have used + to indicate '0A'x On Fri, Apr 11, 2008 at 4:34 PM, toby dunn <tobydunn@hotmail.com> wrote: > Comments = Compress( Comments , 'KW' ) ; > > > > Toby Dunn > > "Don't bail. The best gold is at the bottom of barrels of crap." > Randy Pausch > > "Be prepared. Luck is where preparation meets opportunity." > Randy Pausch > > > > Date: Fri, 11 Apr 2008 10:41:01 -0700 > > From: wardnine@GMAIL.COM > > Subject: Problem with carriage return/newline character when writing SAS database to a text file... > > To: SAS-L@LISTSERV.UGA.EDU > > > > I had a table in Excel which included an ID (identification number), > > COMMENTS, and AMOUNT column. The COMMENTS column were text notes (up > > to 2000 characters) commenting on the corresponding ID. I imported > > this table (via proc import) into a SAS dataset and then used the file > > and put statements to write the dataset to a fixed-length text file > > (i.e., for each record, the ID variabe was outputted to positions 1-4, > > COMMENTS outputted to positions 6-2005, and the AMOUNT column > > outputted to positions 2007-2012). > > > > The ...

running a sas file within a sas file
Sorry to bug you all with such an easy one, but I havent had much luck with the usual help sources. I just want to run a sas program file within a sas program file. For example, in sas file 1 I want to set x equal to 2, then with file 2 invoked by file 1, I want to set y = 3. So sas file 1 looks like this... data data; x = 2; ***How do I invoke sas file 2 which sets y = 3 here???*** run; Thanks!!! On 9 jun, 09:20, zpe...@NATURE.BERKELEY.EDU (Zach Peery) wrote: > Sorry to bug you all with such an easy one, but I havent had much luck > with the usual help sources. > > I just want to run a sas program file within a sas program file. For > example, in sas file 1 I want to set x equal to 2, then with file 2 > invoked by file 1, I want to set y = 3. > > So sas file 1 looks like this... > > data data; > x = 2; > ***How do I invoke sas file 2 which sets y = 3 here???*** > run; > > Thanks!!! Here is a way. sas file 2 saved as your_file_location\inclfile2.sas: y = 3; sas file 1: data test; x = 2; %include 'your_file_location\inclfile2.sas'; put (_all_ ) (=); run; One could think macro, which could operate in much the same way, but can be more flexible. %macro setvar(v=y); &v = 3; %mend setvar; sas file 1: data test; x = 2; %setvar(v=z); put (_all_ ) (=); run; There are other ways as well. My question would be: why would you want this and in this way? Regards, Joep ...

How to add a carriage return when write to text file?
Hi guys, I am trying to write my output to a file. This is what I have so far: char path[256]; sprintf(path,"/example.txt"); if((fd=open(path, O_RDWR, 0))==ERROR) { printf("Error opening file %#x\n",errno); close(fd); } while (bytesPrinted < bytesNeeded) { sprintf (path, "%s \n", OutLine); write (fd, path, 56); } close (fd); I can't get OutLine to write to a new line everytime...The strings are all concatinated on one line in example.txt. How can I add a carriage return in the code so each line will be written to a new line? Thanks for your help, Binh On Mar 19, 4:19=A0pm, Binhminhmatt...@gmail.com wrote: > Hi guys, > > I am trying to write my output to a file. =A0This is what I have so far: > > char path[256]; > sprintf(path,"/example.txt"); > > if((fd=3Dopen(path, O_RDWR, 0))=3D=3DERROR) > { > =A0 =A0 =A0 printf("Error opening file %#x\n",errno); > =A0 =A0 =A0close(fd); > =A0} > > while (bytesPrinted < bytesNeeded) > { > =A0 =A0 =A0 =A0 =A0 sprintf (path, "%s \n", OutLine); > =A0 =A0 =A0 =A0 =A0 write (fd, path, 56);} > > close (fd); > > I can't get OutLine to write to a new line everytime...The strings are > all concatinated on one line in example.txt. =A0How can I add a carriage > return in the code so each line will be written to a new line? > > Thanks for your help, > Binh Oh, ...

Re: Exporting a SAS data set to Text file on SAS unix #3
hi ... actually, what I posted earlier was too much code (sorry) this is enough (a bit more succinct) * variable names into a macro variable (tab separated); proc sql noprint; select name into :vars separated by '09'x from dictionary.columns where libname eq 'SASHELP' and memname eq 'CLASS' order varnum; quit; data _null_; file 'z:\class.txt' dsd dlm='09'x ; if _n_ eq 1 then put "&vars"; set sashelp.class; put (_all_) (:); run; -- Mike Zdeb U@Albany School of Public Health One University Place Rensselaer, New York 12144-3456 P/518-402...

Re: running a sas file within a sas file
Like Joep wrote: that seems to be the right thing for the macro facility. With %include you are very static. With the macro facility that could be very dynamic. The simplest thing is: you could provide the statements you want to insert as parameter: %macro doit(stmt1=,stmt2=); ..... &stmt1 ..... &stmt2 ..... %mend; %doit(stmt1=%str(y=sqrt(y);), stmt2=%str(if y<2 then y=2;) ); with many other things you can do, e.g. conditional creating of statements, naming variables by parameters, create multiple statements with macro loops and much more. On the other hand: if you want to do such simple things like you wrote, avoid any %INC or %MACRO things! It is far more readable, if you don't use %INCLUDES. What do you think, that data-step will do: data a; %inc(inc1); %inc(inc2); %inc(inc3); run; ??? instead of: data a; set sashelp.class; if age>11 then age=11; keep name age; run; Gerhard On Mon, 9 Jun 2008 01:42:03 -0700, Joep Steeman <jsteeman@BUSINESSDECISION.COM> wrote: >On 9 jun, 09:20, zpe...@NATURE.BERKELEY.EDU (Zach Peery) wrote: >> Sorry to bug you all with such an easy one, but I havent had much luck >> with the usual help sources. >> >> I just want to run a sas program file within a sas program file. For >> example, in sas file 1 I want to set x equal to 2, then with file 2 >> invoked by file 1, I want to set y = 3. >> >> So sas file 1 looks like this... >> &g...

SAS/Warehouse Administrator Problem?? or SAS/ACCESS problem??
hello, I've built a process in SAS/Warehouse Administrator, where i'm trying to extract distinct cities from the 3 tables(source schema) in Oracle into a new table (target schema) called CITY and again into UniqueCity (target schema) bcos of some redundancy. The process looks like this. Unique City | | mapping | | CITY ...

Executing separate SAS File from Main SAS File
Hi All I was wondering if I can initiate execution of SAS code stored in a SAS file from my main SAS code. Help very much appreciated. Thanks Toby See %include -----Original Message----- From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu]On Behalf Of tobyrathgeb@stanford.edu Sent: Tuesday, August 02, 2005 2:42 PM To: sas-l@uga.edu Subject: Executing separate SAS File from Main SAS File Hi All I was wondering if I can initiate execution of SAS code stored in a SAS file from my main SAS code. Help very much appreciated. Thanks Toby __________________________________...

SAS Tip: Writing constant text to output files
Have you ever needed to write a constant value out to your text file in addition to the values of various variables? It is really easy to do this. Just put the constant value in quotes and embed it in your put statement along with your variables: data _null_; set one; file 'c:\temp\.....'; put @1 var1 $char5. @10 'TestText' @25 var2 $char2. @30 var3 $char3. etc. ; run; In the above example, the characters 'TestText' will b...

problem with more than 255 columns when importing from text file to SAS
I have SAS Enterprise guide 1.3 on Windows XP. I am trying to import some data in a comma separated text file into SAS. The text file has more than 255 columns, more than 800 in fact. When I try to import this into SAS, it reads only upto 255 columns and then stops. Can someone please help me with this? How do I import more than 255 columns? Thanks in advance Ajay Ajay, file option LRECL will work. The following is a sample code. ============ Kind Regards, Zibao Zhang, MD filename in 'f:\temp\in.txt'; *********************************************************; * Create a .txt file to demo, Hope this file is similar to your data. ; data _null_; file in lrecl=100000; /* USING LRECL, the default is 256!!! this is the problem you met you can set a number larger than that of you data*/ array varlist(*) var1-var1000; do i =1 to 100; do j = 1 to 1000; varlist(j) =int(uniform(123)*10000); end; put var1 -var1000; end; run; *********************************************************; data test; infile in lrecl=100000 truncover; /* USING LRECL, the default is 256!!! TRUNCOVER is a good option to read raw data, please ref to the manual*/ input var1-var1000; run; ----- Original Message ----- From: "Ajay" <ajay_jain@EXCHANGE.ISB.EDU> Newsgroups: bit.listserv.sas-l To: <S...

SAS/Warehouse Administrator Problem?? or SAS/ACCESS problem?? #2
hello, I've built a process in SAS/Warehouse Administrator, where i'm trying to extract distinct cities from the 3 tables(source schema) in Oracle into a new table (target schema) called CITY and again into UniqueCity (target schema) bcos of some redundancy. The process looks like this. Unique City | | mapping | | CITY ...

A character set display problem about SAS Libname engine to access MYSQL database via ODBC
Dear All, I encountered a display problem when I tried to access my MYSQL database via ODBC connection with SAS libname engine. All of the western characters could be displayed correctly in SAS, however, for those non-western characters, such as Chinese and Japanese, they will be displayed as "???". I used the following statement to build the ODBC connection: libname test ODBC dsn=test; I have installed SAS multiple language supportive package and aslo set the environment apprioately. Does anyone could give me some idea about how to resolve this issue? Is there any option to config the character set, such as UTF-8 in the libname engine or elsewhere? Thanks very much Stanley On Mar 3, 1:46=A0am, Stanley Wei <medpo...@gmail.com> wrote: > Dear All, > > I encountered a display problem when I tried to access my MYSQL > database via ODBC connection with SAS libname engine. All of the > western characters could be displayed correctly in SAS, however, for > those non-western characters, such as Chinese and Japanese, they will > be displayed as "???". > > I used the following statement to build the ODBC connection: > > libname test ODBC dsn=3Dtest; > > I have installed SAS multiple language supportive package and asloset > the environment apprioately. Does anyone could give me some idea about > how to resolve this issue? Is there any option to config thecharacterset,= such as UTF-8 in the libname engine or ...

Is there a system option for OpenVMS SAS version 8 where a sas program can create an output file with a file attribute of "Stream_LF" so that these external files can b
To SAS-Lers (specifically OpenVMS Users), Is there a system option for OpenVMS SAS version 8 where a sas program can create an output file with a file attribute of "Stream_LF" so that these external files can be served through an Apache WebServer properly? Currently, what happens is when we create a CSV file, the Apache Webserver wants to load the contents of this CSV file into a single cell for Excel. That is, all OBS are treated as a SINGLE record and all the contents is loaded into a single cell within Excel. To fix this problem, we are able to use an "Convert/FDL" th...

Re: Is there a system option for OpenVMS SAS version 8 where a sas program can create an output file with a file attribute of "Stream_LF" so that these external files c
Charles Patridge <charles_s_patridge@PRODIGY.NET> wrote: > Is there a system option for OpenVMS SAS version 8 where a sas program can > create an output file with a file attribute of "Stream_LF" so that these > external files can be served through an Apache WebServer properly? > > Currently, what happens is when we create a CSV file, the Apache Webserver > wants to load the contents of this CSV file into a single cell for Excel. > That is, all OBS are treated as a SINGLE record and all the contents is > loaded into a single cell within Excel. > > T...

encoding problem with BeautifulSoup
Hi, I am having some encoding problems when I first parse stuff from a non-english website using BeautifulSoup and then write the results to a txt file. I have the text both as a normal (text) and as a unicode string (utext): print repr(text) 'Branie zak\xc2\xb3adnik\xc3\xb3w' print repr(utext) u'Branie zak\xb3adnik\xf3w' print text or print utext (fileSoup.prettify() also shows 'wrong' symbols): Branie zak=B3adnik=F3w Now I am trying to save this to a file but I never get the encoding right. Here is what I tried (+ lot's of different things with encode, decode...

converting sas transport files into sas datasets
Hello All, Could anyone please give me the code for converting sas transport files into sas datasets. thanks in advance. ...

Opening non SAS files with BASE SAS ?
Is there a function that executes a non SAS file? I've written a macro that outputs a file with the extention SQL (EXE would also be helpful). *.SQL files are associated with SQL server on my computer so I'd like to make SAS execute this file so it triggers the SQL server program. Is this possible? Thank You, Aaron ...

Re: Help needed to convert text file to SAS file #3
Thanks for answering my question, that has been solved. Thanks! Nancy "Terjeson, Mark (IM&R)" <Mterjeson@russell.com> wrote: Hi, I'm not sure what all converting or parsing you want to do but here is a method of fetching the parts and pieces. If you need more help, hollar again... * read flat file varying length ; data thedata(drop=pline); length pline $2000 name_part $100 value_part $1000; infile 'c:\temp\myfile.txt' length=lenvar; input @1 pline $varying. lenvar; if pline eq '' then delete; name_part = trim(left(scan(pline,1,':'))); value...

Re: Help needed to convert text file to SAS file #2
My 2p: data i; retain name_part value_part; infile 'c:\temp\sas.txt' dlm = "|}|" /*JUNK DELIMETER.*/ dsd missover lrecl = 440; informat text $440. value_part $422. name_part $28.; input text; if 2 < _N_ < 9 then delete; if text ^ = ""; if text =:"Notes: Spoke with" then text = tranwrd(text,"re:Patient","re.Patient"); name_part = trim(left(scan(text,1,':'))); value_part = trim(left(scan(text,2,':'))); if text=:"Notes: Spoke" then value_part = trim(left(value_part)) || " " || "thx"; if ...

Problems converting *.sas file to a tab delimited file, in Unix environment
Hello May I please ask for your kind help? Unfortunately I don't have any knowldege of SAS. I have a program [I am attaching a copy of this program below] that generates *.sas7bdat files. After I generate a file called abc_out.sas7bdat , I go to the directory where abc_out.sas7bdata is located and type the following command: sas dexport TAB "abc_out.sas7bdat" {I found this command on the Internet, I thought it would generate a tab delimited text file called "TAB"} {Please note that I am typing this command at the Telnet prompt, in Unix environment, as far as I un...

Web resources about - Problem with carriage return/newline character when writing SAS database to a text file... - comp.soft-sys.sas

List of Killzone characters - Wikipedia, the free encyclopedia
Cpl. Dante Garza is a loyal, optimistic and likable character- an effective team player. A close companion of Sev, the pair have served together ...

‘Star Wars: Episode VIII’ set photos leak, reveal new characters
... release until 2017, the movie is being filmed right now and TMZ on Monday scored some exclusive photos from the set that reveal some new characters. ...

A nearly forgotten 'Game of Thrones' character is about to make a huge comeback
While the fate of Jon Snow is getting most of the attention, the return of Bran Stark is one of the most fascinating subplots going into the ...

‘Supergirl’ Cast And Execs Talk Feminism, Gay Characters & ‘The Flash’ Crossover – PaleyFest
The cast and creatives of Supergirl took the stage on Day 3 of PaleyFest to what fans were hoping would be the confirmation of a second season. ...

John Early Channels His ‘Gay Female Comedian’ — And Several Other Characters — In ‘Netflix Presents ...
John Early describes his new Netflix special on ‘The Characters’ as a ‘gay fever dream.’ And what an amazing dream it is.

'Game Of Thrones' Season 6 Spoilers: Will Ian McShane's Character Die In His Debut Episode?
... that sent fans into a hysteria about spoilers. Ian McShane might have possibly dropped another major spoiler about his "Game of Thrones" character. ...

Killer Instinct character leaks hint at General RAAM and Mira releases
By way of a Season 3 leak for Killer Instinct , two new characters may have just been revealed. The first is Mira, who is said to be the sister ...

John Boyega Visits Kids in Hospital Dressed as 'Star Wars' Character
John Boyega Visits Kids in Hospital Dressed as 'Star Wars' Character

The Character Flaws Behind Donald Trump's Terrifying Flirtation With Violence
Many of us assumed there was a method to Donald Trump’s madness: that underneath it all, it was a put-on, reflecting an underlying strategy. ...

Vashon, Sumner High Schools to Incorporate Character Education
... to boost student performance, two more schools in the St. Louis Public School District plan to incorporate life lessons in the classroom. Character ...

Resources last updated: 3/17/2016 8:09:06 AM