Programming the statistical procedures from SAS

Error: Variables not found

Reply
Occasional Contributor
Posts: 12

Error: Variables not found

Hi everyone, I am trying to run the analysis of my school research, but I have been running into several errors in the process. Thanks to several tips from good and knowledgeable people in this support community, I have been able to over come majority of the initial errors that have to do with unsuccessful data importing. The problem at this stage is that error message keep coming up that most of my Error: Variables were not found. Please I will appreciate it anyone can help out and give me a clue on what to do. The log result is as available below:

NOTE: Copyright (c) 2002-2012 by SAS Institute Inc., Cary, NC, USA.

NOTE: SAS (r) Proprietary Software 9.4 (TS1M1)

      Licensed to MISSISSIPPI STATE UNIVERSITY - SFA T&R, Site 70084845.

NOTE: This session is executing on the X64_7PRO  platform.

NOTE: Updated analytical products:

      SAS/STAT 13.1

      SAS/ETS 13.1

      SAS/OR 13.1

      SAS/IML 13.1

      SAS/QC 13.1

NOTE: Additional host information:

X64_7PRO WIN 6.1.7601 Service Pack 1 Workstation

NOTE: SAS initialization used:

      real time           0.94 seconds

      cpu time            0.77 seconds

1    OPTIONS VALIDVARNAME=ANY;

2    PROC IMPORT OUT= WORK.PPTEST2011

3    DATAFILE= "E:\sasmi\DATA2011PontotocTestAges1to4.xlsx"

4        DBMS=EXCELCS;

5        SCANTEXT=YES;

6        USEDATE=YES;

7        SCANTIME=YES;

8    RUN;

NOTE: WORK.PPTEST2011 data set was successfully created.

NOTE: The data set WORK.PPTEST2011 has 481 observations and 24 variables.

NOTE: PROCEDURE IMPORT used (Total process time):

      real time           0.46 seconds

      cpu time            0.14 seconds

9

10       *IF COMM1='99' THEN DELETE;

11       *IF COMM2='99' THEN DELETE;

12

13       VOL2=0.21099+(0.00221*((AGE2D*AGE2D)*AGE2HT));

         ----

         180

ERROR 180-322: Statement is not valid or it is used out of proper order.

14       VOL3=0.21099+(0.00221*((AGE3D*AGE3D)*AGE3HT));

         ----

         180

ERROR 180-322: Statement is not valid or it is used out of proper order.

15       VOL4=0.21099+(0.00221*((AGE4D*AGE4D)*AGE4HT));

         ----

         180

ERROR 180-322: Statement is not valid or it is used out of proper order.

16

17   *PROC SORT;

18       *BY BLOCK CLONE;

19   *PROC MEANS NOPRINT;

20       *BY BLOCK TAXA CLONE;

21   *PROC UNIVARIATE;

22       *VAR AGE1HT AGE2D AGE2HT AGE3D AGE3HT AGE4D AGE4HT VOL2 VOL3 VOL4;

23       *OUT=GENOTYPE MEAN=AGE1HT AGE2D AGE2HT AGE3D AGE3HT AGE4D AGE4HT VOL2 VOL3 VOL4;

24

25   PROC GLM;

26       CLASS BLOCK CLONE;

ERROR: Variable BLOCK not found.

ERROR: Variable CLONE not found.

NOTE: The previous statement has been deleted.

27       MODEL AGE1HT AGE2D AGE2HT AGE3D AGE3HT AGE4D AGE4HT VOL4=BLOCK CLONE BLOCK*CLONE;

ERROR: Variable AGE1HT not found.

ERROR: Variable AGE2D not found.

ERROR: Variable AGE2HT not found.

ERROR: Variable AGE3D not found.

ERROR: Variable AGE3HT not found.

ERROR: Variable AGE4D not found.

ERROR: Variable AGE4HT not found.

ERROR: Variable VOL4 not found.

NOTE: The previous statement has been deleted.

28       LSMEANS BLOCK;

ERROR: Variable BLOCK not found.

NOTE: The previous statement has been deleted.

29       MEANS BLOCK/DUNCAN ALPHA=0.05;

ERROR: Variable BLOCK not found.

NOTE: The previous statement has been deleted.

30       LSMEANS CLONE;

ERROR: Variable CLONE not found.

NOTE: The previous statement has been deleted.

31       MEANS CLONE/DUNCAN ALPHA=0.05;

ERROR: Variable CLONE not found.

NOTE: The previous statement has been deleted.

32   RUN;

NOTE: PROCEDURE GLM used (Total process time):

      real time           2:19.15

      cpu time            2.23 seconds

33   PROC GLM DATA=GENOTYPE;

ERROR: File WORK.GENOTYPE.DATA does not exist.

34       CLASS BLOCK CLONE;

35       MODEL AGE1HT AGE2D AGE2HT AGE3D AGE3HT AGE4D AGE4HT VOL4=BLOCK CLONE;

ERROR: No data set open to look up variables.

ERROR: No data set open to look up variables.

ERROR: No data set open to look up variables.

ERROR: No data set open to look up variables.

ERROR: No data set open to look up variables.

ERROR: No data set open to look up variables.

ERROR: No data set open to look up variables.

ERROR: No data set open to look up variables.

NOTE: The previous statement has been deleted.

36       LSMEANS BLOCK;

37       MEANS BLOCK/DUNCAN ALPHA=0.05;

ERROR: Variable BLOCK not found.

NOTE: The previous statement has been deleted.

38       LSMEANS CLONE;

ERROR: Variable CLONE not found.

NOTE: The previous statement has been deleted.

39       MEANS CLONE /DUNCAN ALPHA=0.05;

ERROR: Variable CLONE not found.

NOTE: The previous statement has been deleted.

40   RUN;

ERROR: A MODEL statement must be given.

Grand Advisor
Posts: 10,026

Re: Error: Variables not found

As minimum the variable VOL4 isn't created as you have data step code OUTSIDE of a data step following the import. It does nothing but generate errors.

25   PROC GLM;

26       CLASS BLOCK CLONE;

The Proc GLM does not reference a specific data set so is likely using the last created dataset which should be WORK.PPTEST2011. If that set does not contain the named variables then you will get the missing variables error.

Second

PROC GLM DATA=GENOTYPE;

ERROR: File WORK.GENOTYPE.DATA does not exist.

tells you why you are getting the missing variable message: There is no data set so there are no variables. Create the dataset WORK.GENOTYPE or point the Proc GLM to an actual existing data set with the named variables.

Occasional Contributor
Posts: 12

Re: Error: Variables not found

Thanks ballardw, the data set;WORK.PPTEST2011 did contain the named variables that were the declared missing, that was why I am so confused.

Grand Advisor
Posts: 10,026

Re: Error: Variables not found

At the time the code was run the error message says that the data set did not exist. You may have looked at it later or earlier, but at that time the set was missing. Maybe a case of WORK is temporary data and not there in a later session of SAS?

Esteemed Advisor
Posts: 6,265

Re: Error: Variables not found

Your problems start in line 13 of the log where you use a datastep-type variable assignment outside of a data step, which constitutes syntactically illegal code. Fix that first.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Respected Advisor
Posts: 4,755

Re: Error: Variables not found

You will need to change your thinking about how a SAS program works.  SAS does not maintain a "current version of your data".  All SAS data sets are available at all points in your program.  For example, you could code:

proc print data=sales; run;

proc print data=pop; run;

proc print data=demog; run;

Just specify on the PROC statement which data set to use and SAS finds it by name.  These three data sets may have been created 500 lines earlier in your program, and many other data sets could have been created in between.

Similarly, when you manipulate data in a DATA step,  you have to tell SAS what data set you are creating, and what data set you are using.  When you code this statement:

VOL2=0.21099+(0.00221*((AGE2D*AGE2D)*AGE2HT));

You might be expecting that SAS knows which data set to use, when applying this formula.  But it doesn't.  You have to specify the complete step, such as:

data PPTEST2011_modified;

   set PPTEST2011;

VOL2=0.21099+(0.00221*((AGE2D*AGE2D)*AGE2HT));

... perhaps some additional data manipulation statements here ...

run.

The DATA and SET statements are missing from your program.  SAS does not know where you would like to store your results, and does know what what the source of data should be when you leave out the DATA and SET statements.

Good luck.

Ask a Question
Discussion stats
  • 5 replies
  • 1059 views
  • 0 likes
  • 4 in conversation