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 (November 2004, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 18 Nov 2004 10:24:05 -0500
Reply-To:     Fred <ieaggie2002@gmail.com>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Fred <ieaggie2002@GMAIL.COM>
Subject:      How to make the array/matrix operation easy in SAS?
Content-Type: text/plain; charset=US-ASCII

Hi, all

I do not know if there is some easy way to handle the array/matrix operation. Suppose I have a data set TEST: data test; input Group Var1 Var2 ; cards; 1 11 10 2 25 20 3 12 3 4 15 30 5 12 24 6 19 40; run;

1) How can I know the length of the above data set,which should be 6.

2) I want to truncate Var1 and Var2. For example, I need to remain the last 4 values in Var1, and keep the first 4 values in Var2. That is, the new data set New_test should be like: 12 10 15 20 12 3 19 30 How can I do this?

3). If I need to truncate the original data set by cutting out 1-3 values from each variable, can I use DO WHILE statement to achieve this, my logice is: i =1: DO WHILE (i<4) NewVar1_{i} = Truncated Var1 by cutting its first i values; NewVar2_{i} = Truncated Var1 by cutting its last i values; i+1; END; Then I can have 6 new data sets: NewVar1_{1} -- NewVar2_{2}. And need to merge the NewVar1_{i} and NewVar2_{i} into a single data set such that they have the same length.

I find it is too difficult in SAS on using array and referring to the specific value in it by an index.

Can anyboday give me some advice?

Thanks.

Fred


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