BookmarkSubscribeRSS Feed
RW9
Diamond | Level 26 RW9
Diamond | Level 26

What you have posted is incorrect.  There is a space before dm where there should be none, and your proc report does uses a different dataset, which has different variables.  What I will do is once again, as you seem to refuse to provide simple requested information, is guess what you want.  I will take your given dm, and order by north american first then Europe, this shows how to create an order variable, and use that in your proc report.  Its the nearest I can get to with limited information.

data dm;
  length region$ 15 ethnicity$ 25 Trtgrp$ 20;
  input studyid$ age height weight BSA region$ sex$ race$ ethnicity$ Trtgrp$;
datalines;
001 50 112 60 2.3 NorthAmerica Men White Caucasian Trt1
002 66 123 62 2.1 NorthAmerica Women White AfricanAmerican Trt1
003 68 136 55 2.6 Europe Women Black Caucasian Trt1
004 70 128 69 1.9 Europe Men White Latino Trt1
005 78 130 74 1.6 NorthAmerica Men White Caucasian Trt1
006 76 124 66 1.8 Europe Women Black AfricanAmerican Trt2
007 77 126 64 2.4 Europe Men Black Caucasian Trt2
008 65 122 70 1.5 NorthAmerica Men White AfricanAmerican Trt1
009 67 132 73 1.3 Europe Men White Caucasian Trt1
010 69 128 76 1.4 NorthAmerica Women Black Caucasian Trt2
;
run;

data dm;
  set dm;
  ord=ifn(race="NorthAmerica",1,2);
run;

proc report data=dm nowd headline spacing = 10;
  columns studyid trtgrp ord race age height weight;
  define ord / noprint;
run;

 

ballardw
Super User

@srav2 wrote:

hi,

 

The sample data is as below. In the final report i need to change the order of the observations in the variable race$.

 

data out. dm;
  length region$ 15 ethnicity$ 25 Trtgrp$ 20;
  input studyid$ age height weight BSA region$ sex$ race$ ethnicity$ Trtgrp$;
  datalines;
  001 50 112 60 2.3 NorthAmerica Men White Caucasian Trt1
  002 66 123 62 2.1 NorthAmerica Women White AfricanAmerican Trt1
  003 68 136 55 2.6 Europe Women Black Caucasian Trt1
  004 70 128 69 1.9 Europe Men White Latino Trt1
  005 78 130 74 1.6 NorthAmerica Men White Caucasian Trt1
  006 76 124 66 1.8 Europe Women Black AfricanAmerican Trt2
  007 77 126 64 2.4 Europe Men Black Caucasian Trt2
  008 65 122 70 1.5 NorthAmerica Men White AfricanAmerican Trt1
  009 67 132 73 1.3 Europe Men White Caucasian Trt1
  010 69 128 76 1.4 NorthAmerica Women Black Caucasian Trt2
;
run;

 

proc report data = out.Demographics nowd headline spacing = 10;
  columns _NAME_ trt1 trt2 total;
  define _NAME_ /display " " center;
  define trt1 /display "TRT1" center;
  define trt2 /display "TRT2" center;
  define total/display "Total" center;
run;


Your proc report does not use the example data, does not use the variable race at all, uses a variable _name_ not in the example data, and you need to describe what order you want race to appear. You say "change the order of the observations in the variable race". To what?

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 16 replies
  • 1716 views
  • 1 like
  • 4 in conversation