Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

proc means label types within a variable

Status
Not open for further replies.

bumed

Technical User
Aug 23, 2007
18
US
Here is my question can you label types within a variable in the by statement. (code) has 6 types (artr, antr, altr, altl, artl, antl) how can I label the mean and std for those types. I know how it can be done for variables. But I can't figure it out for types within a variable. Except for transposing it, is that the only way?


proc means data=arrowsort2 noprint;
by code;
var RTcLag;
output out=mc1 ;
run;
 
What I do in your case is to use numeric data and then a format so that the printout has the new format.
Let me show you:

first give each a type a numeric value. (artr=1, antr=2, altr=3, altl=4, artl=5, antl=6)
Code:
data arrowsort2;
  set arrowsort2;
  if trim(upcase(code)) = 'ARTR' then
    coden = 1;
  if trim(upcase(code)) = 'ANTR' then
    coden = 2;
  if trim(upcase(code)) = 'ALTR' then
    coden = 3;
  if trim(upcase(code)) = 'ALTL' then
    coden = 4;
  if trim(upcase(code)) = 'ARTL' then
    coden = 5;
  if trim(upcase(code)) = 'ANTL' then
    coden = 6;
run;

Then create a format

Code:
proc format;
  value cdfmt
   1 = 'Your label 1'
   2 = 'Your label 2'
   3 = 'Your label 3'
   4 = 'Your label 4'
   5 = 'Your label 5'
   6 = 'Your label 6'
   ;
quit;

Then in your proc means step use the format;

Code:
proc means data=arrowsort2 noprint;
 by code;
 var RTcLag;
 output out=mc1 ;
 format code cdfmt.;
run;

Is this what you need?
Klaz
 
Sorry I was not clear. Maybe this can help you help me. Again code has 6 types but in the output I would like to be able to use each of the six standard deviation and means in a merged data set with arrowsort2. I tried this but it didn't work. Does this help
thanks
Steve

proc means data=arrowsort2 noprint;
by code;
var RTcLag;
output out=mc1 Mean(artr, antr, altr, altl, artl, antl)= martr, mantr, maltr, maltl, martl, mantl std(artr, antr, altr, altl, artl, antl)= sdartr, sdantr, sdaltr, sdaltl, sdartl, sdantl;
run;
 
I think what you need to do is this:-
Code:
proc means data=arrowsort2 noprint;
  by code;
  var RTcLag;
  output out=mc1 Mean=meanlag std=stdlag;
run;

proc transpose data=mc1;
  by code;
  var meanlag;
run;

proc transpose data=mc1;
  by code;
  var stdlag;
run;
If the transpose I've given you is close to what you want, but not quite, I'd recommend checking the doco on it, I'm not an expert at Transpose. NB - You can only transpose 1 variable at a time.

As an aside and suggestion (not trying to be picky or nasty), "It doesn't work" isn't all that helpful. It could mean "There was an error message so the code is incorrect" in which case, we'd need the error message to help, or it could mean "It didn't give me what I wanted" in which case, a brief example of what you wanted, and what you actually got would really help us to understand what you're aiming for.

With this sort of thing, trying to manipulate data in a complex way, I frequently find the easiest way to explain it is to give a brief example of what the data currently looks like, and what you would like it to look like at the end.

Let us know how it goes, if you've managed to solve the problem or if you need further help. :)
Cheers.


Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top