BookmarkSubscribeRSS Feed
melhaf
Fluorite | Level 6

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 */
6 REPLIES 6
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
melhaf
Fluorite | Level 6

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 */

PaigeMiller
Diamond | Level 26

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. 

--
Paige Miller
FreelanceReinh
Jade | Level 19

System option LABEL might be set to NOLABEL. In this case

options label;

should help.

PaigeMiller
Diamond | Level 26

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;

 

--
Paige Miller
melhaf
Fluorite | Level 6

That looks  (at first glance) way better Thank you

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 6 replies
  • 810 views
  • 1 like
  • 3 in conversation