BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

In the following code I don't understand something.

 

In data set QUARTILESx I created 5 new varabiles with following names:

per25  pet50 per75 pmin  pmax

with the following labels:

per25  pet50 per75 pmin  pmax

 

In data set cars2 the labels of these varaibles were changed to MSRP.

Can you please explain why???

 

 

 

Thanks

Joe

 

 

 

 

 

proc report data=cars nowd OUT=QUARTILESx;
column origin type msrp=per25 msrp=per50 msrp=per75 msrp=pmin msrp=pmax;
define origin  / group; 
define type  / group; 
** Define Statistics;
define per25  / p25 'per25';  
define per50 / median 'per50';  
define per75 /  p75 'per75'; 
define pmin / min 'pmin'; 
define pmax / max 'pmax';
run;



data cars2; 
merge cars  QUARTILESx; 
by origin type;
run;

 

4 REPLIES 4
Kurt_Bremser
Super User

Doesn't happen.

Run this code:

proc sort
  data=sashelp.cars
  out=cars
;
by origin type;
run;

proc report data=cars nowd OUT=QUARTILESx;
column origin type msrp=per25 msrp=per50 msrp=per75 msrp=pmin msrp=pmax;
define origin  / group; 
define type  / group; 
** Define Statistics;
define per25  / p25 'per25';  
define per50 / median 'per50';  
define per75 /  p75 'per75'; 
define pmin / min 'pmin'; 
define pmax / max 'pmax';
run;

data cars2; 
merge cars  QUARTILESx; 
by origin type;
run;

proc contents data=cars2;
run;

And look at the result of the CONTENTS procedure:

           Alphabetic List of Variables and Attributes

  #    Variable       Type    Len    Format      Label

  9    Cylinders      Num       8                               
  5    DriveTrain     Char      5                               
  8    EngineSize     Num       8                Engine Size (L)
 10    Horsepower     Num       8                               
  7    Invoice        Num       8    DOLLAR8.                   
 15    Length         Num       8                Length (IN)    
 11    MPG_City       Num       8                MPG (City)     
 12    MPG_Highway    Num       8                MPG (Highway)  
  6    MSRP           Num       8    DOLLAR8.                   
  1    Make           Char     13                               
  2    Model          Char     40                               
  4    Origin         Char      6                Origin         
  3    Type           Char      8                Type           
 13    Weight         Num       8                Weight (LBS)   
 14    Wheelbase      Num       8                Wheelbase (IN) 
 21    _BREAK_        Char     32                               
 16    per25          Num       8    DOLLAR8.    per25          
 17    per50          Num       8    DOLLAR8.    per50          
 18    per75          Num       8    DOLLAR8.    per75          
 20    pmax           Num       8    DOLLAR8.    pmax           
 19    pmin           Num       8    DOLLAR8.    pmin           

The labels are clearly there.

ballardw
Super User

This will do what you describe. Note that the labels are not in the define blocks:

proc report data=cars nowd OUT=QUARTILESx;
column origin type msrp=per25 msrp=per50 msrp=per75 msrp=pmin msrp=pmax;
define origin  / group; 
define type  / group; 
** Define Statistics;
define per25  / p25 ;  
define per50 / median ;  
define per75 /  p75 ; 
define pmin / min ; 
define pmax / max ;
run;

data cars2; 
merge cars  QUARTILESx; 
by origin type;
run;

So, are you sure that the data set you are using was actually created with Proc Report code shown in the first post? Really?

 

Tom
Super User Tom
Super User

Usually when that type of thing happens to me it is because the dataset didn't get updated by the code I ran because I had the previous version of it open (in ViewTable for example) to look at it.

ballardw
Super User

@Tom wrote:

Usually when that type of thing happens to me it is because the dataset didn't get updated by the code I ran because I had the previous version of it open (in ViewTable for example) to look at it.


Which would be clearly indicated in the log with something like this:

ERROR: You cannot open USER.HAVE.DATA for output access with member-level control because
USER.HAVE.DATA is in use by you in resource environment ViewTable Window.

So read the log.

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 617 views
  • 0 likes
  • 4 in conversation