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 (February 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, 18 Feb 2008 09:35:40 -0800
Reply-To:     webonomic <webonomic@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         webonomic <webonomic@GMAIL.COM>
Organization: http://groups.google.com
Subject:      Keeping unique variable while reshaping dataset.
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=ISO-8859-1

The following is a representation of my dataset of survey responses DATA surveys; INPUT surveyID respondent code; CARDS ; 1 1 16 1 . 7 1 . 100 1 . 100 2 1 100 2 . 8 2 . 100 3 1 100 4 1 6 4 . 9 ; run;

There are a total of 4 survey respondents. Each respondent can have 1 or more codes. The respondent variable is given a value of 1 only once for each ID.

I need 2 new datasets. One is where code=100 and the other where code ^=100. Datasteps with only these where clauses produce incorrect datasets because I end up losing the correct representation of respondents.

Where Code^=100 would produce a dataset such that the sum of respondents=2 but it should be 3, because there are 3 unique surveyID's. surveyID respondent code 1 1 16 1 . 7 2 . 8 4 1 6 4 . 9

The resulting dataset I want is: surveyID respondent code 1 1 16 1 . 7 2 1 8 4 1 6 4 . 9

A similar issue occurs for code=100. I could count unique surveyID's to get the correct number of respondents, but I have many other SAS programs dependent on the input of this dataset in this format.

When respondent=1, code may or may not equal 100.

One way to do it would be to assign a 1 to the first 100 for each surveyID then I think my Where clauses would work.

Thank you very much for any help you can give me.


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