JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for ALLSTAT Archives


ALLSTAT Archives

ALLSTAT Archives


allstat@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Monospaced Font

LISTSERV Archives

LISTSERV Archives

ALLSTAT Home

ALLSTAT Home

ALLSTAT  2000

ALLSTAT 2000

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re;SAS programming

From:

"nantana naranong" <[log in to unmask]>

Reply-To:

[log in to unmask]

Date:

Tue, 10 Oct 2000 07:38:05 +0700

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (384 lines)

Hello,
I would like to thank Dr.Martyn Byng ,Dr.John D. McClure,Dr.Miland Joshi and Dr.Kathleen McCaffrey and Dr.Roberto for their repies as below.

I can read and separate two file :head and student file.
I have some quesion as below.
I know head1-head6 variables of student file in each course have an error and the correct one is head1-head6 variables of head file so I would like to copy all variables of head file in each course to head1-head6 of variables of student file in that co
rse.

I tried to write as you advised as below but it has a problem in this part.I spent a lot of time for this,but it did not work.
 
e.g SAS program is as below

option pagesize=60 linesize=80;
data head (keep=head1-head6 )
   student (keep=head1-head6 q1-q8);
array head[6] ;
array temp{6} ;
array q[8] ;
retain head;
infile cards missover;
input head1 1 head2 2-4 head3 5-6 head4 7 head5 8
      head6 9 q1 10 q2 11 q3 12 q4 13 q5 14 q6 15 q7 16 q8 17;

if (head1 = "") then
  output student;
else do;
  do cc = 1 to 6;
     end;
  output head;
end;
cards;
101104021
  1 02153454455
 0110402134455554
 0110402134545545
  1 145555555
 0110422135343333
 0110402142142333
 0111102124555555
101101021
 0112 02124555455
  1 2 02133363343
 0110202123555555
 0112 02 3324434
  111102144554344
 0110202134455445
 0110202 34455345
 0110202144333333
 0110202124555555
 0110202 34263323
  1 2 02 23344434
 011 02133243434
 0112 02 34464444
 0110202134363333
 0112 02122245544
 0110202134545445
 0112 02 22455445
 0112 02135554424
101105021
 0110502123464354
 0115 02144343343
 0115 02123465555
 0115 02123555535
 0115 2123555535
;
run;
title "Head Data";
proc print data=head;run;
title "Student Data";
proc print data=student;
run;
data together;
merge head (rename=(head1=h1 head2=h2 head3=h3 head4=h4 head5=h5 head6=h6 ))
student;
by head;
run;
proc print data=student;
run;



Can anyone know how to use SAS command for these ?
I would also appreciate some comments about these.
Sorry for long message.
 
 Have a nice day!
 Cheers,
 Nantana Naranong
 
 
-------------------------------------------
-----Original Message-----
From: nantana naranong [[log in to unmask]]
Sent: 09 October 2000 00:31
To: [log in to unmask]
Cc: [log in to unmask]
Subject: SAS programming

> Hello,
> I have many data of teaching evaluation approximately 7-8 years.
> The detail is as below.
>
> There are head data and student data in each course.
> The first line is head data and the second line to end are student data in each course.
> These must have column 1-9 the same,but there are some error on student data in these column.
>
> I would like to
> i)read head line and copy all variables to same variables in student lines in each course. And then
> ii)skip head line and read student lines all variables in column 1-17.
>
> Variables in head data are head course section year semester deparment and
> variables in student data are head course section year semester deparment question1-8.
>
> e.g. data is as below.
>
> 101104021 head data in course 101
> *1 02153454455 student data
> *0110402134455554 ....
> *0110402134545545 ....
> * 1 145555555 ....
> *0110422135343333 .....
> *0110402142142333 .....
> *0111102124555555 student data
> 101101021 head data in course 102
> *0112 02124555455 student data
> * 1 2 02133363343 ....
> *0110202123555555 ....
> *0112 02 3324434
> * 111102144554344
> *0110202134455445
> *0110202 34455345
>
> I spent a lot of time for this,but it did not work.
> Can anyone know how to use SAS command for these ?
> I would also appreciate some comments about these.
>
> Have a nice day!
> Cheers,
> Nantana Naranong
>
>
>
---------------------------------------
Date Mon, 9 Oct 2000 14:23:45 0100 (BST)
To nantana naranong <[log in to unmask]>
Author Martyn Byng <[log in to unmask]>
Subject Re: SAS programming

The following section of code should give you something easily to alter.
It makes the following assumptions:

(1) The data is currently being read in from the cards statement. To
change this to an input file remove everything beow (and including) the
line `cards;' and change the infile statement to read
infile file="your filename in here" missover;

(2) All the information is character (you will need to change the array
types if not, by removing `$ 100' if the data is numeric).

(3) The way to distinguish between a students record and the head record
is when the first question is missing (i.e. the sixth record in the
dataset is missing for the head record and present in the student record).


Hope this helps

data head (keep=head1-head5)
   student (keep=head1-head5 q1-q8);
array head[5] $ 100;
array temp[5] $ 100;
array q[8] $ 100;
retain head;
infile cards missover;
input temp1-temp5 q1-q8;
if (q1 ne "") then
  output student;
else do;
  do cc = 1 to 5;
   head[cc] = temp[cc];
  end;
  output head;
end;
cards;
a b c d e
a d d d d 1 2 3 4 5 6 7 8
a a a a a 1 2 3 4 5 6 7 8
;
run;
title "Head Data";
proc print data=head;run;

title "Student Data";
proc print data=student;run;



--------------------------------------------------------
Date Mon, 9 Oct 2000 12:36:06 0100 (BST)
To [log in to unmask]
Author johndm <[log in to unmask]>
Subject Re: SAS programming

Hi,

Queries regarding specific software packages are better sent to
the appropriate software mailing list rather than Allstat.

For example, you might try the sas-l list, details of which can
be found on the Allstat webpage
   http://www.stats.gla.ac.uk/allstat/
under the "Other Statistics Lists" link.

Cheers,

John

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

John D. McClure

Department of Statistics Phone : 44 (0)141 330 6118
University of Glasgow Fax : 44 (0)141 330 4814
       
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[log in to unmask] http://www.stats.gla.ac.uk/allstat
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-------------------------------------------------------------------
Date Mon, 9 Oct 2000 08:47:26 0100
To "[log in to unmask]" <[log in to unmask]>
Author "Joshi, M." <[log in to unmask]>
Subject RE: SAS programming

Hi Nantana

You might be able to carry out your task using row pointers, dealt with on
page 285 of Cody and Smith's Applied Statistics and the SAS Programming
Language (4th ed 1997, ISBN 0137436424). Note that you need the same number
of rows per subject.

So here's one posible answer:

data students;
  input #1 head 1-3 course 4 section 5 year 6-7 semester 8
department 9
   #2 head 1-3 course 4 section 5 year 6-7 semester 8
department 9 question1_8 10-17;
datalines;
.
.
.

etc

[or, use infile statement before input as follows:

data students;
  infile 'a:students.dta';
  input #1 head 1-3 course 4 section 5 year 6-7 semester 8
department 9
   #2 head 1-3 course 4 section 5 year 6-7 semester 8
department 9 question1_8 10-17;
]


The above is only an example, as you have not said exactly how the columns
are split up.
Also, I am not sure how you would deal with missing data unless you cleaned
the data set first. One possibility might be to import the data into another
package and clean it before trying the SAS programme. If you did this in
SPSS or S-Plus you might not need SAS in that case! Anyway, good luck.

Regards
Miland Joshi (Mr.)

Department of Epidemiology and Public Health
University of Leicester


-------------------------------------------------------------
Date Mon, 9 Oct 2000 08:33:58 0100
To <[log in to unmask]>
Author "Kathleen McCaffrey" <[log in to unmask]>
Subject RE: SAS programming

Does one column contain the course number (I can't work that out from the
data you have shown)?
If so, you can use

data heads students;
 set dataset;
 by courseno;
 if first.courseno then output out=heads;
 else if not first.courseno then output students;
run;

You may have already tried that .. but just a suggestion.

Good luck

Kathleen


------------------------------------------------------------
Date Mon, 9 Oct 2000 09:12:00 0100
To [log in to unmask]
Author [log in to unmask]
Subject SAS programming

Try doing it in steps: first, read all data regardless they are head or
student, identifying each variable by specifying the position in the
string, then run a data step putting head data in one file and student data
in another creating a key variable for a merge. Finally, merge them
together on the key variable, renaming variables coming from head.

The following SAS program seems to work on the data you sent by e-mail.

Good luck
Roberto


/* read data */

data prova;
input v1 $1 v2 2 v3 3 v4 4 v5 5 v6 6 v7 7 v8 8 v9 9 v10 10 v11 11
   v12 12 v13 13 v14 14 v15 15 v16 16 v17 17;
cards;
101104021
*1 02153454455
*0110402134455554
*0110402134545545
* 1 145555555
*0110422135343333
*0110402142142333
*0111102124555555
101101021
*0112 02124555455
* 1 2 02133363343
*0110202123555555
*0112 02 3324434
* 111102144554344
*0110202134455445
*0110202 34455345
;
run;


/* separate files */

data head(keep=head v1ok v2-v9)
   student(keep=head v2-v17);
set prova;

if v1 ne '*' then do;
 head 1; * head identifies each new head/student block - key variable for merging;
 v1ok = v1 * 1; * putting alpha variable v1 as numeric;
 output head;
end;

if v1 = '*' then output student;
run;


/* putting all together again */
/* variables from head lines are named h1-h9 */

data toghethe;
merge head(rename=(v1ok=h1 v2=h2 v3=h3 v4=h4 v5=h5 v6=h6 v7=h7 v8=h8 v9=h9))
   student;
by head;
run;

----------------------------------------
 








%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

April 2024
March 2024
February 2024
January 2024
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager