BookmarkSubscribeRSS Feed
axescot78
Quartz | Level 8

I have a dataset that I want to subset by column name. One of the columns I am interested in keeping is named 'MOD'. SAS returns an error when I call on this column; probably because it violates this rule:

 

SAS reserves a few names for automatic variables and variable lists, SAS data sets, and librefs.

 

How can I call on this column? I have to use 'keep' rather than 'drop' because there are 78 columns in this dataset.

5 REPLIES 5
PaigeMiller
Diamond | Level 26

Show us the log of this step, complete, unedited, with nothing chopped out, and in the sequence that it appears in the log. Please click on the </> icon and paste the log as text into the window that appears. DO NOT SKIP THIS STEP.

--
Paige Miller
Tom
Super User Tom
Super User

There are very few (if any) names that SAS will not allow as a variable name.  MOD is definitely a valid variable name.

Example:

123  data test;
124    do mod=1 to 5; output; end;
125  run;

NOTE: The data set WORK.TEST has 5 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.09 seconds
      cpu time            0.03 seconds


126  proc print data=test;
127    where mod=3;
128  run;

NOTE: There were 1 observations read from the data set WORK.TEST.
      WHERE mod=3;
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.12 seconds
      cpu time            0.00 seconds
axescot78
Quartz | Level 8

Thanks Tom. Looking at it again, the error is related to the format:

 

ERROR: The format MOD was not found or could not be loaded.

 

Looking at the proc contents, the column is named MOD and the format is MOD. Must be a custom format!

Tom
Super User Tom
Super User

To use the data without access to the format set the option NOFMTERR.

ballardw
Super User

@axescot78 wrote:

Thanks Tom. Looking at it again, the error is related to the format:

 

ERROR: The format MOD was not found or could not be loaded.

 

Looking at the proc contents, the column is named MOD and the format is MOD. Must be a custom format!


You can change the behavior of missing formats as errors by setting:

 

Options nofmterr;

 

Or create a temporary format that does nothing:

 

Proc format;

   value mod;

run;

 

would find a format but treat the values as the BEST format.

 

Or find the definition for the MOD format and run it in your session.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 6547 views
  • 0 likes
  • 4 in conversation