Re: how to generate an array in sas?

  • Permalink
  • submit to reddit
  • Email
  • Follow


lixiaoyao5880@YAHOO.COM wrote:
>   how to generate a array in sas,I want an array from 1 to 508.

I'm sorry, but I can't tell whatyou're after.

Are you trying to create one record with numbers from 1 to 508, in variables
that
have names like, say, V1 to V508?


  array vv{508} v1-v508;
  do _i = 1 to dim(vv);
    vv{_i} = _i;
    end;


Or are you trying to create records which are numbered from 1 to 508?


  do reccount = 1 to 508;
    output;
    run;


In SAS, the word ARRAY has a specific meaning in the data step.  But in lots
of
other places, 'array' means something else.  Could you write back and be
more
specific?

David
--
David L. Cassell
mathematical statistician
Design Pathways
3115 NW Norwood Pl.
Corvallis OR 97330

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
0
Reply davidlcassell (5567) 12/4/2005 6:39:48 AM

See related articles to this posting


  hi david
  Thanks a lot,I just send you an email,could you please answer my
question? Thanks a lot

0
Reply lixiaoyao5880 (132) 12/4/2005 7:26:32 AM
comp.soft-sys.sas 131356 articles. 29 followers. Post

1 Replies
149 Views

Similar Articles

[PageSpeed] 53


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Re: how to generate an array in sas? #2
lixiaoyao5880@YAHOO.COM wrote back to me: > hi david > Thanks a lot,I just send you an email,could you please answer my >question? Thanks a lot Your email to me went right into my spam filter. Sorry. I imagine it was because of the 36K file you went me (not to SAS-L) that was almost all data. Please don't do that anymore. In the meantime, I see that several SAS gurus have answered your immediate question. But I don't think this is the quesiton you really need answered. If you are, in fact, trying to write your own lags so that you will have lagged-by-one data for mod...

Re: how to generate an array in sas? #3
lixiaoyao5880@yahoo.com wrote to me personally, instead of to SAS-L: > I think the model I wrote to you is called Poisson regression models >in time series. > Could you help me on this? Thanks a lot You really need to write to SAS-L, instead of to me personally. I *really* don't think you have a Poisson regression model. You *may* have a time series problem, although I cannot tell, since you haven't told anyone what your data actually *are*. Your variable A1, which you have described as some kind of 'mortality', seems to be a bunch of numbers between 150 and 20...

Re: urgent : Convert SAS array in to sas variables
Shailesh, Why would you want to do what you ask? What you are asking would create the variable for all observations, but the variables' values would be missing values for every observation except the one on which it is based. Art ----- On Sat, 3 May 2008 23:34:44 -0700, Shailesh <shailesh.tewari@GMAIL.COM> wrote: >In my dataset I have an array variable , say A which has values like >Observation 1 - A[1]= 23 ,A[2]=34, A[3]=45 >Observation 2 - A[11]= 23 ,A[12]=34, A[13]=45 > >I want to create sas variables which should have name A61, A62 , A63, >A64 .......... >...

Re: urgent : Convert SAS array in to sas variables #2
On Sat, 3 May 2008 23:34:44 -0700, Shailesh <shailesh.tewari@GMAIL.COM> wrote: >In my dataset I have an array variable , say A which has values like >Observation 1 - A[1]= 23 ,A[2]=34, A[3]=45 >Observation 2 - A[11]= 23 ,A[12]=34, A[13]=45 > >I want to create sas variables which should have name A61, A62 , A63, >A64 .......... >Similarly for second observation these would be A71, A72, >A73 , A74......... > > >in the same datastep. > >Any help ? > >Regards, >Shailesh Arrays are DATA *step* structures. They do not exists in data *...

how to generate an array in sas?
Hi all how to generate a array in sas,I want an array from 1 to 508. Thanks ...

Re: SAS + ARRAY
Ravi, You don't need an array and yes macro code will work here easily: %macro count(camp_num=); proc sql; create table Count_var as select count (distinct (CIN )) as N from table where campaign_&camp_num is not null; quit; %mend count; %macro loop(start=,stop=); %do I = &start %to &stop; %count(camp_num=&i); %end; %mend loop; %loop(start=1,stop=100); HTH Toby Dunn -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of ravi Sent: Monday, August 02, 2004 11:07 AM To: SAS-L@LISTSERV.UGA.EDU Subject: SAS + ARRAY I have 100...

Re: Generating arrays
Amrita, A sample data set and the required output will find you faster solution . Muthia Kachirayan On 7/5/07, Amrita Singh <amritas2@aol.com> wrote: > > Hi, > > I have a situation where I have to accumulate hundreds of variables that > are in an several arrays. Some arrays have 10 elements whereas other?arrays > may have 80 elements.? > ?? > An?input array may look like this: > > Array?inpvars (*) dollar6mo dollar12mo?items6mo?items12mo ..etc; > > I have to generate an output array?which looks like this: > > array outvars(*) t_dollar6mo t_dol...

Re: SAS Arrays
Code using array is possible. Fix what variables you need to have. Set a sample input dataset and the OUTPUT that you want to derive out of it. Muthia Kachirayan On 10/29/07, Jamie Henderson <jamie.henderson@lloydstsb.co.uk> wrote: > > Apologies for the newbie question, but I was hoping someone will be able > to help with some code I want to write. > > I have monthly account history files going back a few years. I want to > create 1 ever expanding file that contains a couple of pieces of data that > will never change (customer reference number, original borrowing ...

Re: SAS Generated,
One caveat I forgot. The polling instrument will be easier to manage if you reduce the font size in your browser so that all 20 reference axes and the navigation controls are visible on a single page. Otherwise you will have to page down and up as each person is presented. On Sun, Jul 5, 2009 at 8:43 PM, Joe Whitehurst <joewhitehurst@gmail.com>wrote: > This objective presidential poll is unlike any you have ever seen. Unlike > every other presidential poll you have ever encountered which have no > theory to guide their construction, analysis or intrepretation, this > obj...

Re: Generating arrays #5
Hi, I'm not sure why my posting was all messed up - probably the browser I'm using. I like your suggestion of using the second array to do the accumulations...that will work great. Now I just have to get over the hurdle of generating the second array definition which is based on the first array with a prefix. The reason being that I dont want to?manually affix the T_ in front of the hundreds of variables. I was looking for help with some macro code to do that. Thanks for your help. Amrita -----Original Message----- From: Nathaniel.Wooding@dom.com To: amritas2@AOL.COM Cc: SAS...

Re: Generating arrays #9
Nat, Muthia: Thanks so much for your help -?I used your suggestions and got the?results I was looking for. Thanks again, Amrita -----Original Message----- From: Muthia Kachirayan <muthia.kachirayan@gmail.com> To: amritas2@aol.com Cc: SAS-L@listserv.uga.edu Sent: Sat, 7 Jul 2007 2:39 pm Subject: Re: Generating arrays Amrita, Borrowing the idea of Nat here is how it is: data a; infile cards;?????? input custnum dollars items; CARDS;????????????????????????? 5 2 7?????????????????????????? 5 1 0?????????????????????????? 6 2 3?????????????????????????? 6 8 1????????????????????...

Re: SAS + ARRAY #2
On Mon, 2 Aug 2004 09:06:59 -0700, ravi <get_sravikumar@REDIFFMAIL.COM> wrote: >I have 100 campaigns... in the following form. >Campaign_1, Campaign_2 .... Campaign_100. These are columns in a file. >Each of these campaigns contain a certain number of customers. These >numbers change on the monthly basis. My purpose is to find the number >of customers in all these campaigns .. each month. >Objective: >Instead of writing this code 100 times for hundred campaigns, I would >like to see ONE report, which has number of customers for all the >campaigns, beginning...

Re: SAS + ARRAY #3
It could be done in a DATA step, using arrays. But if there are multiple observations for some of the CIN values (which is suggested by the use of the DISTINCT keyword in Ravi's SQL code), it may be tricky. Test data: data campaigns; input cin $ counter campaign_1 campaign_2; cards; A 1 1 . B 1 1 . A 2 1 1 ; I suggest back-to-back PROC SUMMARY steps. First: proc summary data=campaigns nway; class cin; var campaign_ : ; output out=halfdone min=; run; Result: campaign_ campaign_ Obs cin _TYPE_ _FREQ...

Re: sas arrays #8
MT, It sounds like this might be more of a task for PROC IML than a data = step (arrays are called matrixes in IML). Matrixes can be of varying = number of elements. Note that all variables represent a matrix in IML- though the "matrix" = can be 1 by 1, which is essentially a variable like it would be in other = languages. You can pass a variable into a procedure; I'm not quite sure = about the relationships of local variables to global variables like = there are in other language like PL/1. You can also use a macro = variable in IML. Here are some examples of IML that mig...

Re: Use of a sas array
Hi Kende, Is this what you are looking for? This is assuming that the dimensions for array T1 and array T2 are the same. data have; input x1 x2 x3 n1 n2 n3; array T1(3) x1 x2 x3; array T2(3) n1 n2 n3; do _n_=1 to dim(T1); tot = sum(tot,T1[_n_]*T2[_n_] ); end ; cards; 14 6 0 3 2 0 10 7 3 3 2 1 11 5 4 4 2 2 15 2 3 3 1 1 14 3 3 1 1 1 ;run; Output: Obs x1 x2 x3 n1 n2 n3 tot 1 14 6 0 3 2 0 54 2 10 7 3 3 ...

Re: sas arrays #5
On Wed, Mar 5, 2008 at 4:30 PM, MT <mgteixeira@gmail.com> wrote: > Hi, > > I want to be able to manipulate SAS arrays, i.e., adding and removing > elements from an array. Is this possible? it won't be dynamic like in PERL. the size of the array has to be defined first. you can set one of the element to NULL. But as i said, it won't act like auto shrink. > > > Is it possible to define variable-length arrays? I don't know the > final size of an array before doing some processing, and would want > the values to be added to it iteratively. Do you...

Re: sas arrays #7
MT wrote: > Hi, > > I want to be able to manipulate SAS arrays, i.e., adding and removing > elements from an array. Is this possible? > > Is it possible to define variable-length arrays? I don't know the > final size of an array before doing some processing, and would want > the values to be added to it iteratively. Do you know if this is > possible? > > Also, is it possible to redefine a value inside an array at a given > position? The size (number of elements) of a SAS array created with the ARRAY statement is fixed at compile time. The HASH componen...

Re: SAS
you don't need a array for that. What you could do is to use PROC REPORT under ODS -> HTML. In proc report you can access each obs and each column in a COMPUTE block. You can use FLDCOLOR function, or HTML-tags (better) to have influence to cetrtain fields. In the SAS online documentation you'll find examples for that. On Thu, 5 Feb 2009 09:37:14 -0800, bdav1216@GMAIL.COM wrote: >I'm sort of a beginner with SAS so could use an expert's help on this. > >I have a Data File that contains the following variables: > >DATA=SCORED >MA >FG >ACPCOUNTS &...

Re: SAS Arrays #3
On Mon, 29 Oct 2007 08:09:10 -0400, Jamie Henderson <jamie.henderson@LLOYDSTSB.CO.UK> wrote: >Apologies for the newbie question, but I was hoping someone will be able >to help with some code I want to write. > >I have monthly account history files going back a few years. I want to >create 1 ever expanding Do you contemplate expanding by (1) adding observations each month while keeping the number and names of variables the same, or (2) adding variables each month and adding observations only when new accounts are born? #1 is almost always the better choice. If you want...

Re: sas arrays #4
> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On > Behalf Of MT > Sent: Wednesday, March 05, 2008 2:31 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: sas arrays > > Hi, > > I want to be able to manipulate SAS arrays, i.e., adding and removing > elements from an array. Is this possible? > > Is it possible to define variable-length arrays? I don't know the > final size of an array before doing some processing, and would want > the values to be added to it iteratively. Do you know if this is > possible? It i...

Re: SAS Generated, #2
Many thanks to those of you who called my attention to some serious problems with accessing the SAS based, online, objective 2009 Iranian Presidential Poll. I have now fixed most of these problems. I have tested the application with IE 7 and the latest version of Chrome and everything seems to work as desired. I get much better results with Chrome than I do with IE 7, but IE 7 produces usable renderings. If you happen to be using IE 7 (and perhaps other versions of IE, although I have not tested anything but version 7), you will get better results if you set your browser to full screen mod...

Re: Generating arrays #7
Amrita, Borrowing the idea of Nat here is how it is: data a; infile cards; input custnum dollars items; CARDS; 5 2 7 5 1 0 6 2 3 6 8 1 ; run; proc contents data = a out = names(keep=name) noprint; run; proc print data = names; run; data _null_; set names end = eof; length string $200 na $20; retain string; if _n_ ne 1; na = compress('T_'||name); string = compbl(string||na); if eof then call symput('varnames',compbl(string)); run; %*put <&varnames>; data wanted(keep = custnum &varnames); do until(last.custnum); set a; by custnum; array d[*] d...

Re: SAS Generated, #3
Some of you have emailed me saying that when you paused taking the poll and returned later your earlier responses were not there. That's by design. If you do not SAVE your responses, they will not be saved. You must click the SAVE button to save your responses. I apologize for not making that clearer. On Mon, Jul 6, 2009 at 7:44 AM, Joe Whitehurst <joewhitehurst@gmail.com>wrote: > Many thanks to those of you who called my attention to some serious > problems with accessing the SAS based, online, objective 2009 Iranian > Presidential Poll. I have now fixed most of thes...

Re: sas arrays #6
Methinks that HASH object might be useful. I believe it has all the desired properties. Like Dan says, we still don't know what to do. On Wed, Mar 5, 2008 at 4:47 PM, Yu Zhang <zhangyu05@gmail.com> wrote: > On Wed, Mar 5, 2008 at 4:30 PM, MT <mgteixeira@gmail.com> wrote: > > > Hi, > > > > I want to be able to manipulate SAS arrays, i.e., adding and removing > > elements from an array. Is this possible? > > > it won't be dynamic like in PERL. the size of the array has to be defined > first. you can set one of the element to NULL....