BookmarkSubscribeRSS Feed
bigban777
Obsidian | Level 7

Hi, 

I am doing project about how affect meals on blood glucose.

I have following code:

DATA glucose;
	infile 'E:\GLUCOSE.DAT' EXPANDTABS;
	input id g1-g10;
	tm=int((_n_-1)/6)+1;	
run;


DATA missqlucose;
SET glucose;
if g9=-1 then g9=.;
if g10=-1 then g10=.;
run;


PROC plot data=missqlucose (firstobs = 1 obs = 6);
run;

DATA glucose1;
set missqlucose (firstobs = 1 obs = 6);
run;

PROC TRANSPOSE data=glucose1 out=gtrans1 name=time prefix=p;
VAR g1-g10;
run;

PROC PRINT DATA= gtrans1;
run;

Now i need to make one plot of the separate tm class means across gk, where k is from 1:10 (in other words, for g1 g2 g3....g10)

 

P.S. i attached fili that in infile (see above), just change *.txt to *.dat

 

 

2 REPLIES 2
djrisks
Barite | Level 11

Hello,

 

If you just want the mean then you can use the vbar statement in Proc SGPLOT. Below is the code that you can use to get this. I wasn't sure if you wanted means of g1-g10 or means of p1-p6, but you can adjust the code accordingly.

 

PS, it may be useful to see the variation in the data, so you could also look at doing a boxplot. or plotting the mean and confidence intervals.


proc sort data = gtrans1;
  by time;
run;

proc transpose data = gtrans1 out = gtrans_stacked;
  var p1 - p6;
  by time;
run;

proc sgplot data = gtrans_stacked;
  vbar _NAME_ / response = COL1 stat= mean;
run;

bigban777
Obsidian | Level 7

Hi,

Thank you for code. How to put values of means next to each bar on that graph?

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!

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
  • 2 replies
  • 1045 views
  • 2 likes
  • 2 in conversation