|Date: ||Wed, 14 Oct 2009 08:46:17 -0700|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||Jack Hamilton <jfh@STANFORDALUMNI.ORG>|
|Subject: ||Re: Proc Transpose|
|Content-Type: ||text/plain; charset="ISO-8859-1"|
Attachments are not transmitted to the list. You will have to reproduce
them in plain text (best to put a leading character on every line so the
email or list software doesn't strip leading blanks, which it seems to
do randomly, and to keep the lines under 72 characters so they don't
wrap), or put them on a web page where we can see them.
Transpose is like macros - there's almost always a different way to do
whatever you're trying to do, and quite often that other way will be
shorter or more clear, or both. I almost never use transpose.
Both PROC REPORT and PROC TABULATE have the ability to transpose data on
their own. Tabulate is better at it.
On Wed, 14 Oct 2009 11:32:10 -0400, "Carol Thurman"
> Hi All,
> I need to create a report that looks like the pdf document from the raw
> data file (the text file) that I also have attached. The last page of
> the report has a table that compares the assistant principal's
> percentages for each of the competencies to All school Assistant
> Principals in that school region and to All Assistant Principals in the
> entire school district. A region is comprised of a number of schools. Our
> school system has 8 regions.
> I have one text file per school. I was told that I need to first
> transpose the data before using proc tabulate or proc report. I am
> fairly new at this and am having a hard time with proc transpose.
> I have copied the first line of a text file below so you can refer to it.
> N 405001
> The data doesn't start until after the N. The digits prior to the N are
> used by our dispac department when they scan the scantron sheets. After
> the N, the first 3 digits are the school code followed by 001 or 002
> indicating whether or not the respondent is classified staff or
> non-classified staff.
> I have attached the text file and a sample of what the report should look
> like in the end.
> If anyone can help me, I would really appreciate it.
> Thanks so much,
> >>> Arthur Tabachneck <art297@NETSCAPE.NET> 10/12/09 5:05 PM >>>
> Somebody can probably help you more quickly if you provide an example of
> what you expect the final file to look like.
> On Mon, 12 Oct 2009 16:57:29 -0400, Carol Thurman
> >Hi Joe,
> >I tried running what you had but it didn't quite do what I wanted. I don't
> use SAS much so I'm kind of rusty.
> >Thanks for your help. I'll try it again.
> >>>> Joe Matise <email@example.com> 10/12/09 1:34 PM >>>
> >First off, your PROC FORMAT needs to end with a QUIT; statement. Even when
> >it's not needed [say, two data steps after each other], it's much, much
> >neater to code all steps as starting with PROC/DATA/whatever and ending
> >QUIT/RUN as appropriate. Easier to read, and sometimes it does matter.
> >Second, why are you not applying the format in the initial datastep?
> >Third, you might want to just read this in as one step, no transpose. Why
> >not do:
> >data P405;
> > format question $qfmt.;
> > infile io (_p405.yyy) missover;
> > input @41 code 3. @46 Job 1. @;
> > do _t = 52 to length(_infile_);
> > question=substr(_infile_,_t,1);
> > put question=;
> > output;
> > end;
> > drop _t;
> >or something like that (I like to use the _infile_ buffer instead of
> >inputting, as I make fewer mistakes that way, but you may prefer the
> >reverse). Does that give you what you want (many records per job/code, one
> >question answer per record, formatted with your custom format)?
> >On Mon, Oct 12, 2009 at 12:18 PM, Carol Thurman
> >> Hi All,
> >> I would like to get my data so that the string of A's, B's etc go down
> >> columns rather than across. I have written code but when I print the
> >> output, it doesn't look correct. Can someone help me out, please?
> >> I have copied the first line of a text file below ( so you can refer to
> >> it). The data doesn't start until after the N. After
> >> the N, the first 3 digits are the school code followed by 001 or 002
> >> indicating whether or not the respondent is classified staff or
> >> non-classified staff.
> >> Thanks,
> >> Carol
> >> N 405001
> >> THIS IS MY CODE:
> >> filename io 'E:\PAL 2009';
> >> proc format;
> >> value $qfmt A='SA' B='A' C='D' D='SD' E='NA';
> >> data P405;
> >> infile io (_p405.yyy) missover;
> >> input @41 code 3. @46 Job 1. @52 (q1-q78) ($1.);
> >> proc sort data = P405;
> >> by Job;
> >> proc transpose data=P405 OUT= P405T;
> >> by job;
> >> VAR q1-q78;
> >> format q1-q78 $qfmt.;
> >> proc print data=P405T;
> >> run;
firstname.lastname@example.org <== Use this, not jfh @ stanfordalumni.org
Tots units fem força!