A Brief Introduction to PROC TRANSPOSE prepared by Voytek Grus for - PowerPoint PPT Presentation

a brief introduction to proc transpose prepared by voytek grus for n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
A Brief Introduction to PROC TRANSPOSE prepared by Voytek Grus for PowerPoint Presentation
Download Presentation
A Brief Introduction to PROC TRANSPOSE prepared by Voytek Grus for

play fullscreen
1 / 12
A Brief Introduction to PROC TRANSPOSE prepared by Voytek Grus for
315 Views
Download Presentation
lundy
Download Presentation

A Brief Introduction to PROC TRANSPOSE prepared by Voytek Grus for

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. A Brief Introduction to PROC TRANSPOSEprepared byVoytek Grusfor SAS user group, Halifax November 26, 2009

  2. What is data transposition? • Matrix notation: : XT • Excel: copy/paste/transpose command or pivot tables. • Example of a simple data transposition:

  3. Examples of Complex data transpositions Full Transp. Interleaved Dataset

  4. Why do we transpose data? • For data presentation purposes. • To merge datasets with diverse structures • To re-design databases • efficiency gains in programming code and processing time.

  5. Transposing data to streamline SAS calc. and programming code. Cross-sectional data base design Sequential data base design Data Step Array def. Do loop If condition Then output; Run; Proc Transpose This db design is more amenable to sequential data processing using SAS procs with BY statements Proc means, proc regression, proc univariate etc.. Data Step type of processing Data test2; Set test1; Sum= var1+ var2+var3;run;

  6. Syntax of Proc Transpose PROC TRANSPOSE (DATA=input-data-set <LABEL=label> <LET> <NAME=name> ) OUT=output-data-set (drop = _label_ _name_) <PREFIX=prefix>; BY <DESCENDING> variable-1WHERE … (Conditions) … ; VAR (options: list variables, _all_, blank); ID variable; IDLABEL variable; COPY variable(s); • Beware of pitfalls of missing observations and/or duplicate entries in the id variable

  7. SAS Help Tip • Examples: TRANSPOSE Procedure • Example 1: Performing a Simple Transposition • Example 2: Naming Transposed Variables • Example 3: Labeling Transposed Variables • Example 4: Transposing BY Groups • Example 5: Naming Transposed Variables When the ID Variable Has Duplicate Values • Example 6: Transposing Data for Statistical Analysis

  8. An example of proc transpose application in pricing and cost studies from the utility industry • Use divers data bases in pricing studies • Load Research (sample data of 15 min readings) • Power Production (hourly costs) • CIS (monthly records)

  9. Real Life Example (slide 1) • proc transpose data=bd_ets out=bd_ets2; var kwhs kws; • id season daytime _name_; • by year class customer bf psmadj; run;

  10. Real Life Example (slide 2) proctranspose data=bd_ets out=bd_ets2; • var kwhs kws; by year class customer bf psmadj season daytime; run; • data bd_ets2; set bd_ets2; newname=left(right(_name_)||left(season)||left(daytime));run;

  11. Real Life Example (slide 3) • procsort data=bd_ets2 out=bd_ets3; • by class year customer bf psmadj newname;run; • proctranspose data=bd_ets3 out=bd_ets3(drop=_name_); • var col1;id newname; by class year customer bf psmadj;run;

  12. Questions?