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 (October 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 14 Oct 2009 08:46:17 -0700
Reply-To:   jfh@stanfordalumni.org
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Jack Hamilton <jfh@STANFORDALUMNI.ORG>
Subject:   Re: Proc Transpose
Comments:   To: Carol Thurman <erbcjt@LANGATE.GSU.EDU>
In-Reply-To:   <4AD5B6BA020000E20002F2BB@mailsrv4.gsu.edu>
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" <erbcjt@LANGATE.GSU.EDU> said: > 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 > ABBBBBBBAABBBBABBBAABBBBBBAAAABBAAAAAAAABBBBBBBBBAAAAAAAAAAAABBBBBBBBBBBBBBBBB > > > 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, > > Carol > > > >>> Arthur Tabachneck <art297@NETSCAPE.NET> 10/12/09 5:05 PM >>> > Carol, > > Somebody can probably help you more quickly if you provide an example of > what you expect the final file to look like. > > Art > --------- > On Mon, 12 Oct 2009 16:57:29 -0400, Carol Thurman > <erbcjt@LANGATE.GSU.EDU> > wrote: > > >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. > > > >Carol > > > >>>> Joe Matise <snoopy369@gmail.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 > with > >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; > >run; > >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)? > > > >-Joe > > > >On Mon, Oct 12, 2009 at 12:18 PM, Carol Thurman > <erbcjt@langate.gsu.edu>wrote: > > > >> Hi All, > >> > >> I would like to get my data so that the string of A's, B's etc go down > the > >> 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 > >> > >> > ABBBBBBBAABBBBABBBAABBBBBBAAAABBAAAAAAAABBBBBBBBBAAAAAAAAAAAABBBBBBBBBBBBBBB > BB > >> > >> > >> 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; > >>

-- Jack Hamilton Sacramento, California jfh@alumni.stanford.org <== Use this, not jfh @ stanfordalumni.org

Tots units fem força!


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