[prev in list] [next in list] [prev in thread] [next in thread]
List: sas-l
Subject: StackOverflow SAS: Update: SAS Proc Report Specific Setup (datastep and traspose solutions)
From: Roger DeAngelis <rogerjdeangelis () GMAIL ! COM>
Date: 2017-09-28 23:17:27
Message-ID: 5265128479140224.WA.rogerjdeangelisgmail.com () listserv ! uga ! edu
[Download RAW message or body]
/* T1008240 StackOverflow SAS: Update: SAS Proc Report Specific Setup (datastep and traspose solutions)
THREE SOLUTIONS
WPS passed on the datastep and transposed, but failed the 'proc report solution)
WORKING CODE
SAS/WPS
1. * this sets subsequent names to blank;
data want(drop=idx a c d);
retain idx 1 nam b bog hog log ' ';
array ogs[3] $8 bog hog log;
set have;
by b notsorted;
ogs[idx] =d;
if mod(_n_,9)=1 then nam=a;
idx=idx+1;
if last.b then do;
output;
idx=1;
nam='';
end;
2. * this does not set subsequent names to blank (probably better to not set blanks)
proc transpose data=have out=want(drop=d);
by a b;
id c;
var d;
run;quit;
3. WPS output dataset and report failed?
* this does not set subsequent names to blank (probably better to not set blanks)
proc report data=have
out=havxpo(rename=
_C3_ = bog
_C4_ = hog
_C5_ = log));
columns a b c,d n;
define a / group;
define b / group;
define c / across;
define d / display;
define n / noprint;
run;
see
https://stackoverflow.com/questions/46454910/sas-proc-report-specific-setup
Richard profile
https://stackoverflow.com/users/1249962/richard
HAVE
WORK.HAVE total obs=18 RULES (roll Harry Hermione and Ron)
Obs A B C D Bog Hog Log
1 Bill Harry Bog The
2 Bill Harry Hog Quick
3 Bill Harry Log Brown The Quick Brown (one ob out)
4 Bill Hermione Bog Fox
5 Bill Hermione Hog Jumps
6 Bill Hermione Log Over Fox Jumps Over
7 Bill Ron Bog The
8 Bill Ron Hog Lazy
9 Bill Ron Log Dogs
10 Ted Harry Bog Peter
11 Ted Harry Hog Piper
12 Ted Harry Log Picked
13 Ted Hermione Bog A
14 Ted Hermione Hog Powerful
15 Ted Hermione Log Peck
16 Ted Ron Bog Of
17 Ted Ron Hog Picked
18 Ted Ron Log Peppers
WANT
DATASTEP SOLUTION
WORK.WANT total obs=6
Obs NAM B BOG HOG LOG
1 Bill Harry The Quick Brown
2 Hermion Fox Jumps Over
3 Ron The Lazy Dogs
4 Ted Harry Peter Piper Picked
5 Hermion A Powerfu Peck
6 Ron Of Picked Peppers
PROC TRANSPOSE
Up to 40 obs WRK.WANTXPO total obs=6
Obs A B BOG HOG LOG
1 Bill Harry The Quick Brown
2 Bill Hermione Fox Jumps Over
3 Bill Ron The Lazy Dogs
4 Ted Harry Peter Piper Picked
5 Ted Hermione A Powerful Peck
6 Ted Ron Of Picked Peppers
PROC REPORT SOLUTION
Up to 40 obs from havxpo total obs=6
Obs A B BOG HOG LOG N _BREAK_
1 Bill Harry The Quick Brown 3
2 Bill Hermione Fox Jumps Over 3
3 Bill Ron The Lazy Dogs 3
4 Ted Harry Peter Piper Picked 3
5 Ted Hermione A Powerful Peck 3
6 Ted Ron Of Picked Peppers 3
WPS REPORT DATASET (FAILED)
Up to 40 obs from havxpowps total obs=18
Obs A B BOG HOG LOG N _BREAK_
1 Bill Harry The 1
2 Bill Harry Quick 1
3 Bill Harry Brown 1
4 Bill Hermione Fox 1
5 Bill Hermione Jumps 1
6 Bill Hermione Over 1
7 Bill Ron The 1
8 Bill Ron Lazy 1
9 Bill Ron Dogs 1
10 Ted Harry Peter 1
11 Ted Harry Piper 1
12 Ted Harry Picked 1
13 Ted Hermione A 1
14 Ted Hermione Powerful 1
15 Ted Hermione Peck 1
16 Ted Ron Of 1
17 Ted Ron Picked 1
18 Ted Ron Peppers 1
* _ _ _
_ __ ___ __ _| | _____ __| | __ _| |_ __ _
| '_ ` _ \ / _` | |/ / _ \ / _` |/ _` | __/ _` |
| | | | | | (_| | < __/ | (_| | (_| | || (_| |
|_| |_| |_|\__,_|_|\_\___| \__,_|\__,_|\__\__,_|
;
data have;
input A$ B$ C$ D$;
cards4;
Bill Harry Bog The
Bill Harry Hog Quick
Bill Harry Log Brown
Bill Hermione Bog Fox
Bill Hermione Hog Jumps
Bill Hermione Log Over
Bill Ron Bog The
Bill Ron Hog Lazy
Bill Ron Log Dogs
Ted Harry Bog Peter
Ted Harry Hog Piper
Ted Harry Log Picked
Ted Hermione Bog A
Ted Hermione Hog Powerful
Ted Hermione Log Peck
Ted Ron Bog Of
Ted Ron Hog Picked
Ted Ron Log Peppers
;;;;
run;quit;
* _ _ _
___ ___ | |_ _| |_(_) ___ _ __
/ __|/ _ \| | | | | __| |/ _ \| '_ \
\__ \ (_) | | |_| | |_| | (_) | | | |
|___/\___/|_|\__,_|\__|_|\___/|_| |_|
;
%utl_submit_wps64('
libname wrk "%sysfunc(pathname(work))";
data wrk.want(drop=idx a c d);
retain idx 1 nam b bog hog log " ";
array ogs[3] $8 bog hog log;
set wrk.have;
by b notsorted;
ogs[idx] =d;
if mod(_n_,9)=1 then nam=a;
idx=idx+1;
if last.b then do;
output;
idx=1;
nam="";
end;
run;quit;
proc transpose data=wrk.have out=wrk.wantxpo(drop=_name_);
by a b;
id c;
var d;
run;quit;
proc report data=wrk.have
out=wrk.havxpowps(rename=(
_C3_ = bog
_C4_ = hog
_C5_ = log));
columns a b c,d n;
define a / group;
define b / group;
define c / across;
define d / display;
define n / noprint;
run;quit;
');
* works in SAS
proc report data=have
out=havxposas(rename=(
_C3_ = bog
_C4_ = hog
_C5_ = log));
columns a b c,d n;
define a / group;
define b / group;
define c / across;
define d / display;
define n / noprint;
run;quit;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic