I have been at this for a while and i am trying to code the SAS to read all the data I have imputed but it says that it is only reading 7 of the numbers. please help
below I have entered the code that I have made and attached is the original question and data for context
option ls=80; data example; input IGF female weight; cards; 1 24 1.30 1.20 1.09 1.27 1 22 1.15 1.18 1.03 1.10 1 19 1.26 1.24 1.28 1.20 1 10 1.08 1.19 1.04 0.98 2 57 1.13 1.11 0.86 0.91 2 61 1.08 0.94 1.07 1.10 2 52 0.98 0.96 0.94 1.01 2 53 0.92 0.89 0.87 1.07 ; /*these two commands can be used to start a new output file*/ ods html close; ods html; /*these two commands turn the graphic output on and off*/ ods graphics off; /*ods graphics on;*/ proc glm; class IGF weight; model female = IGF weight; lsmeans weight / stderr pdiff; run;
|
When you say "it is only reading 7 of the numbers," can you clarify what you mean? Are you saying that seven of the eight observations are not showing up in your input dataset, or that they are not being used in the GLM procedure?
When I run that code you provided, I see eight observations in example:
...and eight observations read/used by the PROC GLM step:
(Side note: If you're looking at the "7" in the screenshot above, note that two of your observations have the same weight (1.08). If you modify one of those (try 1.09), you'll see eight levels for that.)
i am looking for it to read the 32 weights (g) so i can get the LSMEAN and the variance.
That is why I stated that I was only getting 7
Was what I posted helpful at all? I reconfigured the INPUT statement to get all the data. See previous post.
Jim
I think you may need to adjust your Input statement. Your current input statement does not look like it will retrieve all the data.
I might try recoding it like the following, below. The results are below the code. Is this more in line with what you'd like to have the data look like?
Jim
data example;
input
Control_Nbr $
Female_Nbr $
weight1 - weight4
;
cards;
1 24 1.30 1.20 1.09 1.27
1 22 1.15 1.18 1.03 1.10
1 19 1.26 1.24 1.28 1.20
1 10 1.08 1.19 1.04 0.98
2 57 1.13 1.11 0.86 0.91
2 61 1.08 0.94 1.07 1.10
2 52 0.98 0.96 0.94 1.01
2 53 0.92 0.89 0.87 1.07
;
run;
Which results in the following:
Control_Nbr Female_Nbr weight1 weight2 weight3 weight4 1 24 1.3 1.2 1.09 1.27 1 22 1.15 1.18 1.03 1.1 1 19 1.26 1.24 1.28 1.2 1 10 1.08 1.19 1.04 0.98 2 57 1.13 1.11 0.86 0.91 2 61 1.08 0.94 1.07 1.1 2 52 0.98 0.96 0.94 1.01 2 53 0.92 0.89 0.87 1.07
yes this is helpful.
What would you do for the proc glm
I have
class weight1 - weight4
model Female_nbr = Control_nbr Weight1- weight4
LSMEAN weight1 - weight 4
Well, for one thing LSMEAN needs to be changed to LSMEANS. 🙂
I'm a programmer not a statistician, so I would feel uncomfortable at this juncture to give you advice, particularly not knowing the full context.
I can however say that the code did run once I made the above mentioned small correction.
data example;
input
Control_Nbr
Female_Nbr
weight1 - weight4
;
cards;
1 24 1.30 1.20 1.09 1.27
1 22 1.15 1.18 1.03 1.10
1 19 1.26 1.24 1.28 1.20
1 10 1.08 1.19 1.04 0.98
2 57 1.13 1.11 0.86 0.91
2 61 1.08 0.94 1.07 1.10
2 52 0.98 0.96 0.94 1.01
2 53 0.92 0.89 0.87 1.07
;
run;
proc glm DATA=Example;
class weight1 - weight4 ;
model Female_nbr = Control_nbr Weight1- weight4;
LSMEANS weight1 - weight4;
run;
Jim
What you might want to do, and this is just a thought, is to mark this post as "solved" and open a new thread with "Need help with Proc GLM" or something like that in the title. This post is entitled "how do I get all the date to be read" (which I think we have in fact solved) which will bring in people who are more inclined to programming but might not catch the attention of someone who is experienced with Proc GLM. Just a suggestion.
Jim
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!
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.