Date: Thu, 3 Jul 2008 01:41:39 -0700
Reply-To: Daniel Nordlund <djnordlund@VERIZON.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Daniel Nordlund <djnordlund@VERIZON.NET>
Subject: Re: how to access the data of a dataset?
In-Reply-To: <980ca327-9336-41b5-b6fe-d130f712303f@m44g2000hsc.googlegroups.com>
Content-type: text/plain; charset=UTF-8
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> domenico
> Sent: Thursday, July 03, 2008 12:51 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: how to access the data of a dataset?
>
> On 2 Lug, 17:47, Nord...@DSHS.WA.GOV ("Nordlund, Dan (DSHS/RDA)")
> wrote:
> >If you write back to SAS-L with a description of the problem that
> you are trying to solve, someone will be able to get you started in
> the right direction.
>
> I need to access to a dataset by considering the observation number
> and the variable number.
> For example, if "tb" is my sas dataset, how can I access to this data
> without using the proc iml?
> If I consider the proc iml, I can do:
>
> proc iml;
> use tb;
> read all into mtx;
>
> .......
> k=mtx[1,2]
> ......
> quit;
>
> and so on.
>
> I want to obtain the data of tb (observation 1, variable 2) without
> using the proc iml.
> For example, how to create a sas dataset with only a value equal to
> the observation 1 and the variable 2 of tb? ("calling" this value by
> considering the position into the dataset tb, that is: observation 1
> and variable 2).
>
> What a document freely downloadable and printable (perhaps in pdf) to
> better understand sas? The link suggested by Michael A. Raithel is
> great but you can not print on paper.
>
> thank you
>
> dom
Well, I can tell you how to do what you ask for, but you don't really want to do it. It is almost certainly the wrong thing to do. I will assume that all your variables in tb are numeric and that tb is randomly accessible (e.g. on disk). You could do something like
**----here is some data----**;
data tb;
array v[*] v1-v10;
do _n_ = 1 to 100;
do _j = 1 to 10;
v[_j] = normal(53172);
end;
output;
end;
drop _: ;
run;
**----select the value of the second variable in observation 1----**;
data one_value(keep=value);
obsnum = 1;
varnum = 2;
set tb point = obsnum;
array v[*] _numeric_;
value=v[varnum];
output;
stop;
run;
Now that I have shown you how to get what you asked for, let me say again that you don't want to do this. This is the wrong way to think about data step programming. It is possible to load values into an array in a data step much as you would in Proc iml, but that may not be what you ought to be doing either. Without knowing what your real programming task is (the real problem you are trying to solve), I really can't offer what I believe is good advice.
As an aside, I believe the online SAS documentation that Michael Raithel pointed to is available in pdf format.
Dan
Daniel Nordlund
Bothell, WA USA
|