delete labels and formats

How to delete labels and formats from SAS variables?

To delete labels and formats from SAS variables, use the PROC DATASET  procedure and attrib statement. Consider the example dataset ex with label and formats applied.

data ex;
	a=10.3;
	b=20.5;
	attrib a format=dollar10.2 label='VARIABLE A' b format=dollar10.2 
		label='VARIABLE B';
run;

How to delete labels and formats form a variable?

To delete a variable label and format, use the PROC DATASETS procedure as below.

proc datasets lib=work memtype=data;
	modify ex;
	attrib a label=' ';
	attrib a format='';
	run;
quit;

ods select Variables;
proc contents data=ex;
run;
ods select default;

How to delete labels and formats form a variable?

To delete labels and formats from all the variables replace the attrib statement as below.

attrib _all_ label=' ';
attrib _all_ format='';

Every week we'll send you SAS tips and in-depth tutorials

JOIN OUR COMMUNITY OF SAS Programmers!

Subhro

Subhro provides valuable and informative content on SAS, offering a comprehensive understanding of SAS concepts. We have been creating SAS tutorials since 2019, and 9to5sas has become one of the leading free SAS resources available on the internet.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This Post Has 4 Comments

  1. anjaneyulu

    32 proc datasets lib=work memtype=data;
    33
    33 ! modify ex;
    34 attrib a label=’ ‘;
    35 attrib a format=”;
    __
    22
    200
    ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, ;, FORMAT, INFORMAT, LABEL, LENGTH, _ALL_,
    _CHARACTER_, _CHAR_, _NUMERIC_.
    ERROR 200-322: The symbol is not recognized and will be ignored.

    1. Subhro

      Looking at the error, it seems there is only one quote in the

      attrib a format=”
      

      The correct syntax is

      attrib a format="";
      

      When you copy any code, it is always good to format the code, so you can see the statements and any syntax error like this. To indent the code in SAS EG select all the code and press Ctrl +i

  2. anjaneyulu

    Hi,
    I copied the code given and executed the same. It throws above error.
    can we have both run; and quit; in proc dataset ?

    1. Subhro

      Yes you can use both.