Why is SAS giving me ** as valid values?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 131
Accepted Solution

Why is SAS giving me ** as valid values?

Hello:

I ran proc freqs on a set of numeric variables and the proc freq is displaying ** as one of the valid values.  My dataset does not have ** as any of the valid values.  Would anyone know why this may be happening?

I applied a format to the numeric variables where if the valid value was -99999 then it should display as .M, if -100000=.N, etc.

Thank you!


Accepted Solutions
Solution
‎09-30-2014 10:34 AM
Super User
Super User
Posts: 6,364

Re: Why is SAS giving me ** as valid values?

This seems like a different question than the original one.

Since you only have a MAX of 2 characters in any labels that you have defined in your example format then perhaps it is just that SAS has decided that the default length to use is 2.  You could use another length when you use the format.  MISS10. for example.

Also note that you can define an OTHER class in the format definition.

And you can nest format references.  Which would be useful if you wanted to apply this to a date variable like in your last example.

proc format ;

  value miss -99999 = 'M' -100000='N' -100001='U'

    other = [yymmdd10.]

  ;

run;

data have ;

  do datevar=19731,19732,-99999,-100000,-100001;

    output;

  end;

  format datevar miss. ;

run;

proc freq;

tables datevar;

run;

View solution in original post


All Replies
Super User
Super User
Posts: 6,364

Re: Why is SAS giving me ** as valid values?

That looks like what Excel will do when a value is too large for the width of the column.

Frequent Contributor
Posts: 131

Re: Why is SAS giving me ** as valid values?

Thanks, Tom! Yes, that's helpful because it turns out SAS was displaying ** instead of all my data or income valid values.

I guess, then, I just have to change the width/some settings for my proc freq ODS tables

Frequent Contributor
Posts: 131

Re: Why is SAS giving me ** as valid values?

Hi Tom,


do you know what I could do to get SAS to display my numeric valid values instead of the **?  I didn't apply any settings to my html proc freq tables. The valid values display for one set of numeric variables but not another.

Should I clarify?

many thanks in advance!

Super User
Super User
Posts: 6,364

Re: Why is SAS giving me ** as valid values?

Can you post a very simple example of a program that has a value that is not displaying properly? 

Frequent Contributor
Posts: 131

Re: Why is SAS giving me ** as valid values?

Sure!

code.PNG

Super User
Super User
Posts: 6,364

Re: Why is SAS giving me ** as valid values?

The actual code would be much easier to use that a picture of the code Smiley Happy

Also instead of a data step referencing a table we do not have access to read you should include a simple data step that either sets the values with assignment statements or reads some values from inline card (datalines) images.

Are the values that are printing as ** the ones that you are trying to display as two letter strings that look like how SAS normally displays special missing values .M, .N and .U?  Or are other values also appearing as **.

Frequent Contributor
Posts: 131

Re: Why is SAS giving me ** as valid values?

Hi Tom,

Thanks for the advice on printing code =)  Perhaps because of my IE browser version, I can't paste SAS code into the box without using the HTML version... so, for proc freqs esp I end up using images.

Other values - no the ".M", ".N", ".U" - are the ones which are displaying as **

Thanks so much,

Maisha

Frequent Contributor
Posts: 131

Re: Why is SAS giving me ** as valid values?

If I do a proc freq after the first and second data steps, then the date valid values appear fine (see below).  However, after applying the format, the date valid values become **...

freq1.PNG

Solution
‎09-30-2014 10:34 AM
Super User
Super User
Posts: 6,364

Re: Why is SAS giving me ** as valid values?

This seems like a different question than the original one.

Since you only have a MAX of 2 characters in any labels that you have defined in your example format then perhaps it is just that SAS has decided that the default length to use is 2.  You could use another length when you use the format.  MISS10. for example.

Also note that you can define an OTHER class in the format definition.

And you can nest format references.  Which would be useful if you wanted to apply this to a date variable like in your last example.

proc format ;

  value miss -99999 = 'M' -100000='N' -100001='U'

    other = [yymmdd10.]

  ;

run;

data have ;

  do datevar=19731,19732,-99999,-100000,-100001;

    output;

  end;

  format datevar miss. ;

run;

proc freq;

tables datevar;

run;

Frequent Contributor
Posts: 131

Re: Why is SAS giving me ** as valid values?

Thanks so much, Tom.

That's where my problem was - the proc format step.

Looks like that s what the problem was (my format telling SAS the default length for numbers was 2) and it solved the problem to set the format length to 10

Thanks again!

☑ This topic is SOLVED.

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

Discussion stats
  • 10 replies
  • 304 views
  • 3 likes
  • 2 in conversation