Label statement not working...

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

Label statement not working...

I want to create a label for some variables that I have created.  For some reason, this is not working.  Here is what I have:

data samples;

  set samples;

  label Visit1="May 2013, Visit 1"

       Visit2="June 2013, Visit 1"

       Visit3="June 2013, Visit 2"         

       Visit4="July 2013, Visit 1"

       Visit5="July 2013, Visit 2"

       Visit6="August 2013, Visit 1"    

       Visit7="August 2013, Visit 2"

       Visit8="September 2013, Visit 1"

       Visit9="September 2013, Visit 2"

       Visit10="October 2013, Visit 1"

       Visit11="October 2013, Visit 2";

  run;

When I run this, no labels are created for the variables.

What am I missin


Accepted Solutions
Solution
‎10-30-2013 01:18 PM
Occasional Contributor
Posts: 19

Re: Label statement not working...

Figured it out.  Very stupid.  For some reason when I wrote preceding code, I used options nolabel; and turned labels off.  This was needed for... something... and i need to rediscover what that was.

Once I used options: label; my code label statement worked.

Thanks for the help anyway.

View solution in original post


All Replies
Super User
Posts: 17,784

Re: Label statement not working...

1. Try creating new dataset instead of overwriting the current one, ie data samples2 rather than data samples.

2. Run a proc print to verify the labels are created:

proc print data=samples2 label;

var visit:;

run;

Occasional Contributor
Posts: 19

Re: Label statement not working...

I've tired this but creating the new dataset does not resolve the issue.  I ran proc print and no labels.

Super User
Posts: 17,784

Re: Label statement not working...

Post your full code and log, as well as a proc contents for your dataset.

If you've run this a bunch of times, you may need to recreate the samples dataset for it to work.

Super User
Posts: 5,081

Re: Label statement not working...

Reeza has the right idea here.  PROC PRINT does not use the variable labels, unless you add the word LABEL to the PROC PRINT statement.  PROC CONTENTS would be an easy tool to see whether the labels have been created.  There is nothing wrong with the code that you posted so far.

Occasional Contributor
Posts: 19

Re: Label statement not working...

OK.  I'm not sure how to get the proc contents output into a format for posting...

data samples (keep=SubjectID Visit1-Visit11 EnrollmentStatus UnenrollmentDate MayFilterPaper1 MayRNA1 MayFilterPaper2 MayRNA2 JuneFilterPaper1 JuneRNA1 JuneFilterPaper2 JuneRNA2

  JulyFilterPaper1 JulyRNA1 JulyFilterPaper2 JulyRNA2 AugustFilterPaper1 AugustRNA1 AugustFilterPaper2 AugustRNA2

  SeptemberFilterPaper1 SeptemberRNA1 SeptemberFilterPaper2 SeptemberRNA2

  OctoberFilterPaper1 OctoberRNA1 OctoberFilterPaper2 OctoberRNA2 MayVisit1);

  retain SubjectID EnrollmentStatus UnenrollmentDate;

  merge visitstemp visits;

  format SubjectID ML_Format.;

  /* The following creates a simple to use Visit Date list. The "Visit1-11" format allows simple calling of

  ranges in SAS. The labels section creates label headers needed for simple use in updating BSI.*/

  if MayRNA1="Yes" and MayFilterPaper1="Yes" then Visit1=MayVisit1;

  if JuneRNA1="Yes" and JuneFilterPaper1="Yes" then Visit2=JuneVisit1;

  if JuneRNA2="Yes" and JuneFilterPaper2="Yes" then Visit3=JuneVisit2;

  if JulyRNA1="Yes" and JulyFilterPaper1="Yes" then Visit4=JulyVisit1;

  if JulyRNA2="Yes" and JulyFilterPaper2="Yes" then Visit5=JulyVisit2;

  if AugustRNA1="Yes" and AugustFilterPaper1="Yes" then Visit6=AugustVisit1;

  if AugustRNA2="Yes" and AugustFilterPaper2="Yes" then Visit7=AugustVisit2;

  if SeptemberRNA1="Yes" and SeptemberFilterPaper1="Yes" then Visit8=SeptemberVisit1;

  if SeptemberRNA2="Yes" and SeptemberFilterPaper2="Yes" then Visit9=SeptemberVisit2;

  if OctoberRNA1="Yes" and OctoberFilterPaper1="Yes" then Visit10=OctoberVisit1;

  if OctoberRNA2="Yes" and OctoberFilterPaper2="Yes" then Visit11=OctoberVisit2;

  format Visit1-Visit11 mmddyy10.;

run;

data samples2;

  set samples;

  label Visit1="May 2013, Visit 1"

  Visit2="June 2013, Visit 1"

  Visit3="June 2013, Visit 2"

  Visit4="July 2013, Visit 1"

  Visit5="July 2013, Visit 2"

  Visit6="August 2013, Visit 1"

  Visit7="August 2013, Visit 2"

  Visit8="September 2013, Visit 1"

  Visit9="September 2013, Visit 2"

  Visit10="October 2013, Visit 1"

  Visit11="October 2013, Visit 2";

  run;

proc print data=Samples2 label;

run;

LOG:

1948  data samples (keep=SubjectID Visit1-Visit11 EnrollmentStatus UnenrollmentDate

1948! MayFilterPaper1 MayRNA1 MayFilterPaper2 MayRNA2 JuneFilterPaper1 JuneRNA1 JuneFilterPaper2

1948! JuneRNA2

1949                  JulyFilterPaper1 JulyRNA1 JulyFilterPaper2 JulyRNA2 AugustFilterPaper1

1949! AugustRNA1 AugustFilterPaper2 AugustRNA2

1950                  SeptemberFilterPaper1 SeptemberRNA1 SeptemberFilterPaper2 SeptemberRNA2

1951                  OctoberFilterPaper1 OctoberRNA1 OctoberFilterPaper2 OctoberRNA2 MayVisit1);

1952      retain SubjectID EnrollmentStatus UnenrollmentDate;

1953      merge visitstemp visits;

1954      format SubjectID ML_Format.;

1955

1956      /* The following creates a simple to use Visit Date list. The "Visit1-11" format allows

1956! simple calling of

1957          ranges in SAS. The labels section creates label headers needed for simple use in

1957! updating BSI.*/

1958      if MayRNA1="Yes" and MayFilterPaper1="Yes" then Visit1=MayVisit1;

1959      if JuneRNA1="Yes" and JuneFilterPaper1="Yes" then Visit2=JuneVisit1;

1960      if JuneRNA2="Yes" and JuneFilterPaper2="Yes" then Visit3=JuneVisit2;

1961      if JulyRNA1="Yes" and JulyFilterPaper1="Yes" then Visit4=JulyVisit1;

1962      if JulyRNA2="Yes" and JulyFilterPaper2="Yes" then Visit5=JulyVisit2;

1963      if AugustRNA1="Yes" and AugustFilterPaper1="Yes" then Visit6=AugustVisit1;

1964      if AugustRNA2="Yes" and AugustFilterPaper2="Yes" then Visit7=AugustVisit2;

1965      if SeptemberRNA1="Yes" and SeptemberFilterPaper1="Yes" then Visit8=SeptemberVisit1;

1966      if SeptemberRNA2="Yes" and SeptemberFilterPaper2="Yes" then Visit9=SeptemberVisit2;

1967      if OctoberRNA1="Yes" and OctoberFilterPaper1="Yes" then Visit10=OctoberVisit1;

1968      if OctoberRNA2="Yes" and OctoberFilterPaper2="Yes" then Visit11=OctoberVisit2;

1969

1970      format Visit1-Visit11 mmddyy10.;

1971  run;

WARNING: The variable MayFilterPaper2 in the DROP, KEEP, or RENAME list has never been referenced.

WARNING: The variable MayRNA2 in the DROP, KEEP, or RENAME list has never been referenced.

NOTE: There were 500 observations read from the data set WORK.VISITSTEMP.

NOTE: There were 500 observations read from the data set WORK.VISITS.

NOTE: The data set WORK.SAMPLES has 500 observations and 37 variables.

NOTE: DATA statement used (Total process time):

      real time           0.06 seconds

      cpu time            0.00 seconds

1972

1973

1974  data samples2;

1975      set samples;

1976      label   Visit1="May 2013, Visit 1"

1977              Visit2="June 2013, Visit 1"

1978              Visit3="June 2013, Visit 2"

1979              Visit4="July 2013, Visit 1"

1980              Visit5="July 2013, Visit 2"

1981              Visit6="August 2013, Visit 1"

1982              Visit7="August 2013, Visit 2"

1983              Visit8="September 2013, Visit 1"

1984              Visit9="September 2013, Visit 2"

1985              Visit10="October 2013, Visit 1"

1986              Visit11="October 2013, Visit 2";

1987      run;

NOTE: There were 500 observations read from the data set WORK.SAMPLES.

NOTE: The data set WORK.SAMPLES2 has 500 observations and 37 variables.

NOTE: DATA statement used (Total process time):

      real time           0.03 seconds

      cpu time            0.03 seconds

1988

1989  proc print data=Samples2 label;

1990  run;

NOTE: There were 500 observations read from the data set WORK.SAMPLES2.

NOTE: PROCEDURE PRINT used (Total process time):

      real time           0.87 seconds

      cpu time            0.76 seconds

1991

1992  proc contents data=samples2;

1993  run;

NOTE: PROCEDURE CONTENTS used (Total process time):

      real time           0.12 seconds

      cpu time            0.04 seconds

Occasional Contributor
Posts: 19

Re: Label statement not working...

The SAS System     11:25 Wednesday, October 30, 2013 195

                                      The CONTENTS Procedure

                           Alphabetic List of Variables and Attributes

               #    Variable                 Type    Len    Format        Informat

              21    SeptemberFilterPaper2    Char      8

              20    SeptemberRNA1            Char      8

              22    SeptemberRNA2            Char      8

               1    SubjectID                Num       8    ML_FORMAT.

               3    UnenrollmentDate         Num       8    MMDDYY10.     DDMMYY10.

              27    Visit1                   Num       8    MMDDYY10.

              28    Visit2                   Num       8    MMDDYY10.

              29    Visit3                   Num       8    MMDDYY10.

              30    Visit4                   Num       8    MMDDYY10.

              31    Visit5                   Num       8    MMDDYY10.

              32    Visit6                   Num       8    MMDDYY10.

              33    Visit7                   Num       8    MMDDYY10.

              34    Visit8                   Num       8    MMDDYY10.

              35    Visit9                   Num       8    MMDDYY10.

              36    Visit10                  Num       8    MMDDYY10.

              37    Visit11                  Num       8    MMDDYY10.

Occasional Contributor
Posts: 19

Re: Label statement not working...

The variables are not even showing up in the dataset when I click on the variable.  If I enter manually there, the variable stays.  If I use code.  Nothing.

Occasional Contributor
Posts: 19

Re: Label statement not working...

Could it be that the dataset that i am trying to create labels for was created with proc sql?  I've noticed that my raw datasets have labels but after proc sql, the labels are gone.

Solution
‎10-30-2013 01:18 PM
Occasional Contributor
Posts: 19

Re: Label statement not working...

Figured it out.  Very stupid.  For some reason when I wrote preceding code, I used options nolabel; and turned labels off.  This was needed for... something... and i need to rediscover what that was.

Once I used options: label; my code label statement worked.

Thanks for the help anyway.

New User
Posts: 1

Re: Label statement not working...

It totally just happened to me too, this post was useful, thanks!

 

 

☑ This topic is SOLVED.

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

Discussion stats
  • 10 replies
  • 2309 views
  • 0 likes
  • 4 in conversation