LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 21 Apr 2008 14:21:04 -0400
Reply-To:     Sigurd Hermansen <HERMANS1@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Sigurd Hermansen <HERMANS1@WESTAT.COM>
Subject:      Re: What happened to my special missing values?
Comments: To: hoffman@ria.buffalo.edu
In-Reply-To:  <OFF580544F.672BFF83-ON85257432.0060CFDD-85257432.0062D99B@ria.buffalo.edu>
Content-Type: text/plain; charset="windows-1255"

Joe: The same FORMAT statement that works in a Data step also works similarly in a PROC FREQ. data want; missing U; input x; cards; 1 2 U 2 1 ; run;

PROC FORMAT; VALUE fynunk 1 = 'Yes' 2 = 'No' .U = 'Unknown'; RUN;

PROC FREQ DATA = want; TABLES x / MISSPRINT; format x fynunk.; RUN;

SAS actually has more than one way to trigger printing of formatted values, but the FORMAT statement seems simplest. S

-----Original Message----- From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu] On Behalf Of hoffman@ria.buffalo.edu Sent: Monday, April 21, 2008 1:59 PM To: SAS-L@LISTSERV.UGA.EDU Subject: What happened to my special missing values?

Dear SAS-L ers: I am an experienced SPSS user but novice at SAS doing some data analysis on a large survey data set, using SAS 9.1.3 for Windows. Many variables in this data set had missing values that were coded using numeric values like "9" to indicate "unknown" responses. I wanted to preserve these as special missing values (SPSS would call them "user missing" values), so I created special formats for them, re-coded numeric missing values to SAS special missing values (e.g., change "9" to ".U" which has a format that labels this value as "Unknown"). An example of my code is shown below. Initially this worked fine (see first output sample), but I later re-ran PROC FREQ and found that my special missing values had apparently disappeared, and were all displaying as regular missings (see second output sample). I reviewed my steps and found that I did one other file operation in between these two PROC FREQ runs: I had sorted my data set on some other variables and then replaced the data set with the sorted data set. But why would that have caused my special missings (e.g., ".U") to apparently disappear?

I'd like to get these special missings to display correctly on PROC FREQ output again, but I don't want to have to re-do this formatting for many variables in the data set.

Thanks for any ideas.

Sincerely, Joe Hoffman

LIBNAME library 'C:\SDATA'; OPTIONS FMTSEARCH=(library); PROC FORMAT LIBRARY=library;

VALUE fynunk 1 = 'Yes' 2 = 'No' .U = 'Unknown'; RUN;

DATA SDATA.want; SET SDATA.have;

if s4aq1 = 9 then s4aq1 = .U; /* Unknown */ LABEL s4aq1 = 'Ever had 2-week period when felt sad, blue, depressed, or down most of time'; FORMAT s4aq1 fynunk.; RUN;

PROC FREQ DATA = SDATA.want; TABLES s4aq1 / MISSPRINT; RUN;

The SAS System 13:25 Monday, April 21, 2008 1

The FREQ Procedure

Ever had 2-week period when felt sad, blue, depressed, or down most of time

Cumulative Cumulative S4AQ1 Frequency Percent Frequency Percent ャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャ Unknown 892 . . . Yes 12785 30.30 12785 30.30 No 29416 69.70 42201 100.00

Frequency Missing = 892

Later, after sorting the data set and re-saving it, I get this:

The SAS System

The FREQ Procedure

Ever had 2-week period when felt sad, blue, depressed, or down most of time

Cumulative Cumulative S4AQ1 Frequency Percent Frequency Percent ャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャ . 892 . . . Yes 12785 30.30 12785 30.30 No 29416 69.70 42201 100.00

Frequency Missing = 892

=================================== Joe Hoffman Data Analyst Research Institute on Addictions State University of New York at Buffalo 1021 Main Street Buffalo NY 14203 phone (716) 887-2219 FAX (716) 887-2510 e-mail hoffman@ria.buffalo.edu ===================================


Back to: Top of message | Previous page | Main SAS-L page