DATA Step, Macro, Functions and more

Error Variable Type of Name unknown

Accepted Solution Solved
Reply
Highlighted
Frequent Contributor
Posts: 119
Accepted Solution

Error Variable Type of Name unknown

 

 

I don't undersand why I am getting this message. Maybe someone can see what I do not. The log is here.

 

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 61         
 62         Libname Review'/folders/myfolders/Review' ;
 NOTE: Libref REVIEW was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders/Review
 63         Libname Learn'/folders/myfolders/Learn' ;
 NOTE: Libref LEARN refers to the same physical library as LEARN2.
 NOTE: Libref LEARN was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders/Learn
 64         Libname myformat'/folders/myfolders/sasuser.v94' ;
 NOTE: Libref MYFORMAT refers to the same physical library as SASUSER.
 NOTE: Libref MYFORMAT was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders/sasuser.v94
 65         Options fmtsearch=(myformat) ;
 66         
 67         Proc tabulate data=learn.college noseps ;
 68         class ClassRank ;
 69         Var GPA ;
 70         Tables (Schoolsize All),
 71            ((GPA Classrank)*(Median Min Max)*f=5.1) ;
 72         Label SchoolSize = 'School Size'
 73               ClassRank = 'Class Rank' ;
 74         Keylabel N = ' '
 75                  Min = 'Minimum'
 76                  Max = 'Maximum'
 77                  All = 'Total' ;
 78         run ;
 
 ERROR: The type of name (Schoolsize) is unknown.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE TABULATE used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 78       !      
 79         
 80         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 93         

Below is the code

 

Libname Review'/folders/myfolders/Review' ;
Libname Learn'/folders/myfolders/Learn' ;  
Libname myformat'/folders/myfolders/sasuser.v94' ; 
Options fmtsearch=(myformat) ;

Proc tabulate data=learn.college noseps ; 
	class ClassRank ; 
	Var GPA ; 
	Tables (Schoolsize All),
		   ((GPA Classrank)*(Median Min Max)*f=5.1) ; 
	Label SchoolSize = 'School Size' 
	      ClassRank = 'Class Rank' ; 
	Keylabel N = ' ' 
	         Min = 'Minimum'
	         Max = 'Maximum'
	         All = 'Total' ;
run ;	 

Below is the code for the data set learn.college.

 

data learn.college;
   length StudentID $ 5 Gender SchoolSize $ 1;
   do i = 1 to 100;
      StudentID = put(round(ranuni(123456)*10000),z5.);
      if ranuni(0) lt .4 then Gender = 'M';
      else Gender = 'F';
      if ranuni(0) lt .3 then SchoolSize = 'S';
      else if ranuni(0) lt .7 then SchoolSize = 'M';
      else SchoolSize = 'L';
      if ranuni(0) lt .2 then Scholarship = 'Y';
      else Scholarship = 'N';
      GPA = round(rannor(0)*.5 + 3.5,.01);
      if GPA gt 4 then GPA = 4;
      ClassRank = int(ranuni(0)*60 + 41);  /* the + 41 is there because of missing data (my note) */
      if ranuni(0) lt .1 then call missing(ClassRank);
      if ranuni(0) lt .05 then call missing(SchoolSize);
      if ranuni(0) lt .05 then call missing(GPA);
      output;
   end;
   format Gender $gender1. 
          SchoolSize $size. 
          Scholarship $yesno.;
   drop i;
run;

Accepted Solutions
Solution
Thursday
Super User
Posts: 12,994

Re: Error Variable Type of Name unknown

Posted in reply to ManitobaMoose

Proc tabulate needs to know how a particular variable is to be used. CLASS variables are for grouping, and by default will exclude records if the value for the class variable is missing. You can requested only count related statistics directly for Class variables such as N, PctN, RowPctN, ColPctN, RepPctN, PagePctN. VAR variables can have any of the available statistics requested but do not create groups or subgroups of results.

View solution in original post


All Replies
Super User
Posts: 9,548

Re: Error Variable Type of Name unknown

Posted in reply to ManitobaMoose

Another case for Maxim 1:

From http://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.3&docsetId=proc&docsetTarget=p1g617vn...:

Requirement: All variables in the TABLE statement must appear in either the VAR statement or the CLASS statement.
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Solution
Thursday
Super User
Posts: 12,994

Re: Error Variable Type of Name unknown

Posted in reply to ManitobaMoose

Proc tabulate needs to know how a particular variable is to be used. CLASS variables are for grouping, and by default will exclude records if the value for the class variable is missing. You can requested only count related statistics directly for Class variables such as N, PctN, RowPctN, ColPctN, RepPctN, PagePctN. VAR variables can have any of the available statistics requested but do not create groups or subgroups of results.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 86 views
  • 0 likes
  • 3 in conversation