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 (September 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 27 Sep 2006 05:44:21 -0700
Reply-To:   "J. Manuel Picaza" <JMPicaza@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "J. Manuel Picaza" <JMPicaza@GMAIL.COM>
Organization:   http://groups.google.com
Subject:   Re: Reading in raw files and concatenating text
Comments:   To: sas-l@uga.edu
In-Reply-To:   <MPG.1f83846b4b712dd19896ef@news.chi.sbcglobal.net>
Content-Type:   text/plain; charset="iso-8859-1"

Hello Paula,

See below an easy way to solve your problem. The solution is OK but I think that the structure in the txt is more robust that the one you want to get. In fact if you want to store poetry you need the number of line of the poem in order to print it well.

PROC IMPORT OUT= WORK.problem DATAFILE= "C:\path\to\your\file.txt" DBMS=DLM REPLACE; DELIMITER=';'; GETNAMES=NO; DATAROW=1; RUN;

proc sort data=problem(keep=var1 var2 var8); by var1 var2; run;

data solution(keep=var1 x); set problem; by var1; length x $10000; /*take care of the max length you are going to use*/ retain x;

if first.var1 AND last.var1 then x=trim(var8); else if first.var1 then x=trim(var8); else x=compbl(x||" "||trim(var8)); if last.var1 then output; run;

Paula Sims wrote: > Hello everyone, > I need help receiving a raw file and am having a hard time figuring out > how to read it in. > Here's a sample of the raw file: > > > 1234;1; ; ; ; ; ;Four score and seven years ago our fathers brought; > 1234;2; ; ; ; ; ;forth on this continent, a new nation, conceived in > 1234;3; ; ; ; ; ;Liberty, and dedicated to the proposition that all; > 1234;4; ; ; ; ; ;men are created equal; > 2345;1; ; ; ; ; ;To be or not to be; > 3456;1; ; ; ; ; ;When in the course of human events it becomes; > 3456;2; ; ; ; ; ;necessary for one people to dissolve the political; > > > As you can see, the last text line is broken up and the 2nd column > denotes the number of lines in the text field. So what I want is one > record such as > > 1234 1 Four score and seven years ago our fathers brought forth > on this continent, a new nation, conceived in Liberty, and > dedicated to the proposition that all men are created equal > 2345 1 To be or not to be > 3456 1 When in the course of human events it becomes necessary for > one people to dissolve the political > > > I get that I'm supposed to do an IF test on the 2nd column, but how do I > get the last line to concatenate with the text? > > Thanks so much! > > Paula


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