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 2003, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 30 Apr 2003 17:09:30 +0100
Reply-To:     Nigel.Pain@SCOTLAND.GSI.GOV.UK
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Nigel Pain <Nigel.Pain@SCOTLAND.GSI.GOV.UK>
Subject:      Re: creating new observations in data step
Comments: To: clencar@INTERCHANGE.UBC.CA
Content-Type: text/plain; charset="iso-8859-1"

******************************************************************************************************************************************************* This email and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed. *******************************************************************************************************************************************************

Here's my method (I've no doubt it can be done more efficiently):

DATA newds; KEEP plotid species htclass; ARRAY htclss{*} htclass1-htclass4; SET oldds; DO i=1 TO DIM(htclss); IF htclss{i} > 0 THEN DO j = 1 TO htclss{i}; htclass = i; OUTPUT; END; END; RUN;

*************************************************** Nigel Pain Scottish Executive Analytical Services Team Victoria Quay EDINBURGH EH6 6QQ UK Tel +44 131 244 7237

Mailto:nigel.pain@scotland.gsi.gov.uk Website: http:\\www.scotland.gov.uk

-----Original Message----- From: Cornel lencar [mailto:clencar@INTERCHANGE.UBC.CA] Sent: 30 April 2003 05:21 Subject: creating new observations in data step

Hi all,

I am a not very good SAS user in terms of coding. I have a dataset organised as follows:

PLOTID SPECIES COUNT HTCLASS1 HTCLASS2 HTCLASS3 HTCLASS4 xxx Sx 5 2 2 1 .

And I need to transform it in something like this

PLOTID SPECIES HTCLASS xxx Sx 1 xxx Sx 1 xxx Sx 2 xxx Sx 2 xxx Sx 3

Therefore I need to go within each line through each HTCLASS, establish the number and generate as many rows as that number indicates, keeping in the new table only the PLOTID SPECIES and HTCLASS. I am aware that can be more than one way to do it, and conceptually I would know what are the steps of the algorithm, but I lack the "communications skills".

Any help would be greatly appreciated.

Cornel Lencar


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