- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'm having an issue squaring my X variable to create a new variable... I don't know where to place this transformation statement, or exactly what it should be. Here is my best guess so far, but it keeps telling me "Variable X2 is not found."
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Changing a LABEL in PROC CONTENTS does not create a new variable X2 nor does it assign new values to the variable. If a given observation had a value of 4, after your PROC CONTENTS it sill has a value of 4, not 16. This is all easily viewed in your data set, you could see that for yourself by simply looking at work.import1 after PROC CONTENTS.
You need a SAS data step to compute a variable that has new values.
data import2;
set import1;
x2=x**2;
run;
An even simpler approach is to NOT explicitly compute x**2 by yourself prior to the regression, and to use PROC GLM for the regression, which will compute x**2 internally in the procedure.
proc glm data=import1;
model y = x x*x;
run;
quit;
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@PaigeMiller (or anyone)
I "feel" that squaring of an independent variable MUST be done INSIDE the model statement.
Of course, Statistics is not about feelings, but is my intuition correct?
Or can it be done either way: Inside or outside?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
As far as I know, either way works and should give the same answer (if done properly). Easy enough for you to test.
Paige Miller