Prev: Finding the variables with all missing values
Next: Proc logistic: how to add constraints on variables?
From: Tom Abernathy on 24 May 2010 16:19 There is also Named input. http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#/documentation/cdl/en/lrdict/63026/HTML/default/a000148147.htm But I doubt that this input file is in the proper structure for that. On May 24, 3:43 pm, RolandRB <rolandbe...(a)hotmail.com> wrote: > On 24 Mai, 14:12, RolandRB <rolandbe...(a)hotmail.com> wrote: > > > > > > > On 22 Mai, 04:53, Steve <steve.d...(a)asu.edu> wrote: > > > > I have a long text file where each line represents one of 10 different > > > text or date variables. Each variable line starts with its own > > > identifier (like Recnum: or Start_Date:). The variable RECNUM > > > indicates the start of a new 10-line record; the variable Final is the > > > last one in the record. At each encounter of RECNUM I want to loop > > > through the variables until I hit another RECNUM, and then output the > > > 10 variables into one record, then do it again for all 600 records in > > > the text. > > > > Unfortunately, it's been 15 years since I've done any serious SAS > > > programming, though I > > > have v. 9.2 handy (but no SAS docs around). Can someone point me to a > > > sample program that does the following: > > > -- Steps through a text file with multiple lines for each record, with > > > each line representing one variable; > > > -- Uses IF-THEN-ELSE statements to read the start of each line to > > > detect which variable is being read and saved; > > > -- Outputs the record into a SAS dataset once the last line in a > > > record has been read; > > > -- Then clears all the variables and does the above over again at the > > > beginning of the next record in the text, until all records are read. > > > > I know it's pretty simple because I've written programs like this in > > > the distant past. But I don't remember the details of the necessary @s > > > and RETAINs and such. So thanks for any guidance you can offer. > > > Like this: > > > data test; > > input @'Recnum: ' recnum @'Start_date: ' date ddmmyy10. @'Final: ' > > final; > > format data date9.; > > datalines; > > Recnum: 1 > > Start_date: 23/10/1954 > > Final: 9 > > Recnum: 2 > > Start_date: 23/05/2010 > > Final: 999 > > ;;;; > > run; > > options nocenter nodate nonumber; > > proc print data=test; > > run;- Zitierten Text ausblenden - > > > - Zitierten Text anzeigen - > > I should point out that thse identifiers would have to all exist and > in the same order for code like mine to work. The reason I submitted > it is because a lot of sas programmers are not aware of input using > labels as I am illustrating.
First
|
Prev
|
Pages: 1 2 Prev: Finding the variables with all missing values Next: Proc logistic: how to add constraints on variables? |