BookmarkSubscribeRSS Feed
oldrainbow
Calcite | Level 5

Hi,

I am trying to run this code below, but I am getting an error message all the time that says:

"type is not in the scope of variables for the data set"

Please help! if you need the data set I can email it to you.

Please, please help!

Thank you,

Oldrainbow

Options ls=78;

Title "Turtle Carapace Analysis==2-Sample Hotellings Tsquare";run;

data turtle1;

  Infile "C:\HSRD8111\turtle.txt";

  Input length width height;

  run;

proc iml;

  start hotel2;

    n1=nrow(x1);

    n2=nrow(x2);

    k=ncol(x1);

    one1=j(n1,1,1);

    one2=j(n2,1,1);

    ident1=i(n1);

    ident2=i(n2);

    ybar1=x1`*one1/n1;

    s1=x1`*(ident1-one1*one1`/n1)*x1/(n1-1.0);

    print n1 ybar1;

    print s1;

    ybar2=x2`*one2/n2;

    s2=x2`*(ident2-one2*one2`/n2)*x2/(n2-1.0);

    print n2 ybar2;

    print s2;

    spool=((n1-1.0)*s1+(n2-1.0)*s2)/(n1+n2-2.0);

    print spool;

    t2=(ybar1-ybar2)`*inv(spool*(1/n1+1/n2))*(ybar1-ybar2);

    f=(n1+n2-k-1)*t2/k/(n1+n2-2);

    df1=k;

    df2=n1+n2-k-1;

    p=1-probf(f,df1,df2);

    print t2 f df1 df2 p;

  finish;

  use turtle1;

    read all var {length width height} where (type="female") into x1;

    read all var {length width height} where (type="male") into x2;

  run hotel2;

  quit;

4 REPLIES 4
art297
Opal | Level 21

I think you will have more success at finding an answer if you move this post over to the iml forum.

oldrainbow
Calcite | Level 5

I am totally new here.. I really appreciate your advice. I'll look for it.

IanWakeling
Barite | Level 11

SAS is expecting to find a (character) variable in the turtle1 dataset called "type", however it only contains the three variables: length, width and height.  Try modifying the datastep to read the extra variable, along the lines of:

  Input length width height type : $6.;

oldrainbow
Calcite | Level 5

Thanks, it worked!

Wonderful! I cant thank you enough!!

Thanks so much!!

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!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 4 replies
  • 2282 views
  • 3 likes
  • 3 in conversation