How can I fix this code? _LABEL_ can't be found. And the results Pctls_trp_trp, imo dosen't look very nice. with _NAME_ and col1-col14.
Can someone help me with the _LABEL_ ?
proc univariate data=sashelp.shoes noprint;
var Sales Inventory Returns;
output out=Pctls pctlpts = 5 10 20 25 30 40 50 60 75 80 90 95
pctlpre = Sales_ Inventory_ Returns_
pctlname = pctl5 pctl10 pctl20 pctl25 pctl30 pctl40
pctl50 pctl60 pctl75 pctl80 pctl90 pctl95
mean=Sales_mean Inventory_mean Returns_mean
std =Sales_std Inventory_std Returns_std ;
run;
PROC TRANSPOSE data=Pctls out=Pctls_trp;
run;
data Pctls_trp;
set Pctls_trp;
_NAME_=scan(_NAME_,1,'_');
run;
proc sort data=Pctls_trp;
by _NAME_;
run;
proc transpose data=Pctls_trp out=Pctls_trp_trp;
by _NAME_;
id _LABEL_;
var col1;
run;
/* end of program */
Your program runs without errors when I run it.
Perhaps the results don't look nice to you, what do you want the results to look like? You haven't said. Please explain or better yet show us what you want the results to look like.
Usually there are much better ways to produce tables (PROC REPORT, PROC TABULATE) that don't require transpose or double transpose.
proc univariate data=sashelp.shoes noprint;
NOTE: Writing HTML Body file: sashtml.htm
2 var Sales Inventory Returns;
3 output out=Pctls pctlpts = 5 10 20 25 30 40 50 60 75 80 90 95
4 pctlpre = Sales_ Inventory_ Returns_
5 pctlname = pctl5 pctl10 pctl20 pctl25 pctl30 pctl40
6 pctl50 pctl60 pctl75 pctl80 pctl90 pctl95
7 mean=Sales_mean Inventory_mean Returns_mean
8 std =Sales_std Inventory_std Returns_std ;
9 run;
NOTE: The data set WORK.PCTLS has 1 observations and 42 variables.
NOTE: PROCEDURE UNIVARIATE used (Total process time):
real time 0.63 seconds
cpu time 0.31 seconds
10
11 PROC TRANSPOSE data=Pctls out=Pctls_trp;
12 run;
NOTE: There were 1 observations read from the data set WORK.PCTLS.
NOTE: The data set WORK.PCTLS_TRP has 42 observations and 2 variables.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
13
14 data Pctls_trp;
15 set Pctls_trp;
16 _NAME_=scan(_NAME_,1,'_');
17 run;
NOTE: There were 42 observations read from the data set WORK.PCTLS_TRP.
NOTE: The data set WORK.PCTLS_TRP has 42 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
18
19 proc sort data=Pctls_trp;
20 by _NAME_;
21 run;
NOTE: There were 42 observations read from the data set WORK.PCTLS_TRP.
NOTE: The data set WORK.PCTLS_TRP has 42 observations and 2 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
22
23 proc transpose data=Pctls_trp out=Pctls_trp_trp;
24 by _NAME_;
25 id _LABEL_;
ERROR: Variable _LABEL_ not found.
26 var col1;
27 run;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.PCTLS_TRP_TRP may be incomplete. When this step was stopped
there were 0 observations and 0 variables.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
28 /* end of program */
I don't know why you get this error, I do not get this error.
1 proc univariate data=sashelp.shoes noprint;
2 var Sales Inventory Returns;
3 output out=Pctls pctlpts = 5 10 20 25 30 40 50 60 75 80 90 95
4 pctlpre = Sales_ Inventory_ Returns_
5 pctlname = pctl5 pctl10 pctl20 pctl25 pctl30 pctl40
6 pctl50 pctl60 pctl75 pctl80 pctl90 pctl95
7 mean=Sales_mean Inventory_mean Returns_mean
8 std =Sales_std Inventory_std Returns_std ;
9 run;
NOTE: The data set WORK.PCTLS has 1 observations and 42 variables.
NOTE: Compressing data set WORK.PCTLS increased size by 100.00 percent.
Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: PROCEDURE UNIVARIATE used (Total process time):
real time 0.10 seconds
cpu time 0.04 seconds
10
11 PROC TRANSPOSE data=Pctls out=Pctls_trp;
12 run;
NOTE: There were 1 observations read from the data set WORK.PCTLS.
NOTE: The data set WORK.PCTLS_TRP has 42 observations and 3 variables.
NOTE: Compressing data set WORK.PCTLS_TRP increased size by 100.00 percent.
Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
real time 0.04 seconds
cpu time 0.04 seconds
13
14 data Pctls_trp;
15 set Pctls_trp;
16 _NAME_=scan(_NAME_,1,'_');
17 run;
NOTE: There were 42 observations read from the data set WORK.PCTLS_TRP.
NOTE: The data set WORK.PCTLS_TRP has 42 observations and 3 variables.
NOTE: Compressing data set WORK.PCTLS_TRP increased size by 100.00 percent.
Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
real time 0.10 seconds
cpu time 0.07 seconds
18
19 proc sort data=Pctls_trp;
20 by _NAME_;
21 run;
NOTE: There were 42 observations read from the data set WORK.PCTLS_TRP.
NOTE: The data set WORK.PCTLS_TRP has 42 observations and 3 variables.
NOTE: Compressing data set WORK.PCTLS_TRP increased size by 100.00 percent.
Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.05 seconds
cpu time 0.03 seconds
22
23 proc transpose data=Pctls_trp out=Pctls_trp_trp;
24 by _NAME_;
25 id _LABEL_;
26 var col1;
27 run;
NOTE: There were 42 observations read from the data set WORK.PCTLS_TRP.
NOTE: The data set WORK.PCTLS_TRP_TRP has 3 observations and 43 variables.
NOTE: Compressing data set WORK.PCTLS_TRP_TRP increased size by 100.00 percent.
Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
real time 0.05 seconds
cpu time 0.04 seconds
Please answer my question about what output you want to see.
Is this the output you want?
ods output summary=summary;
proc means data=sashelp.shoes n mean std p5 p10 p20 /* I'm lazy, you type the rest */ stackods;
var sales inventory returns;
run;
That looks (at first glance) way better Thank you
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.