Prev: sample size determination
Next: About sgpanel
From: "Data _null_;" on 17 Dec 2009 11:41 What is you specify TYPE in the SAS variable list? "ID1-character-ID10" This actually changes the list from an enumerated list to a name range list but it might still work. data test; attrib id1 id2 id4 id9 length=$10; attrib id3 id5-id8 id10 length=8; input (id1-id10)(:); cards; id1 id2 3 id4 5 6 7 8 id9 10 id1 id2 3 id4 5 6 7 8 id9 10 id1 id2 3 id4 5 6 7 8 id9 10 ;;;; run; data test2; set test; array a_ID[*] ID1-character-ID10; array b_ID[*] ID1-numeric-ID10; put (a_id[*] b_id[*]) (=); run; On 12/16/09, Sdlentertd <sdlentertd(a)gmail.com> wrote: > On Dec 16, 12:29 pm, barry.a.schw...(a)BOEING.COM ("Schwarz, Barry A") > wrote: > > Arrays are not related to datasets but to variables. It is perfectly acceptable to have multiple arrays dealing with different variables, such as > > > > ARRAY a_array(*) $ var_a1-var_a9; > > ARRAY b_array(*) var_b1-var_b23; > > > > Different arrays can have different dimensions (9 vs 23 in the example) and types (character vs numeric). > > > > Date9. is a format which has nothing to do with arrays. It only affects how a numeric variable is converted to a character string in the PUT function or the PUT statement. (Date and time variables are just normal numeric variables with special meanings attached to the values.) > > > > > > > > -----Original Message----- > > From: SAS(r) Discussion [mailto:SA...(a)LISTSERV.UGA.EDU] On Behalf Of Sdlentertd > > Sent: Tuesday, December 15, 2009 11:57 AM > > To: SA...(a)LISTSERV.UGA.EDU > > Subject: Re: Array use? > > > > <snip> > > > > This is great and works, but > > what if one of the fields that has to be in array is in different > > format than the other, for example: ID1 is character but another field > > is Date which is Date9. and another field Price which is numeric.... > > How do i put them all in one array? or how can I do two seperate > > arrays for one dataset? Thank you- Hide quoted text - > > > > - Show quoted text - > But the statements bellow do not work > array a_ID(*) $ ID1-ID10; (character) > array b_ID(*) ID1-ID10; (numeric) > Error message: All variables in array list must be the same type, > i.e., all numeric or character. >
From: xlr82sas on 18 Dec 2009 01:13 On Dec 17, 8:41 am, iebup...(a)GMAIL.COM ("Data _null_;") wrote: > What is you specify TYPE in the SAS variable list? > "ID1-character-ID10" This actually changes the list from an > enumerated list to a name range list but it might still work. > > data test; > attrib id1 id2 id4 id9 length=$10; > attrib id3 id5-id8 id10 length=8; > input (id1-id10)(:); > cards; > id1 id2 3 id4 5 6 7 8 id9 10 > id1 id2 3 id4 5 6 7 8 id9 10 > id1 id2 3 id4 5 6 7 8 id9 10 > ;;;; > run; > data test2; > set test; > arraya_ID[*] ID1-character-ID10; > arrayb_ID[*] ID1-numeric-ID10; > put (a_id[*] b_id[*]) (=); > run; > > On 12/16/09, Sdlentertd <sdlente...(a)gmail.com> wrote: > > > > > On Dec 16, 12:29 pm, barry.a.schw...(a)BOEING.COM ("Schwarz, Barry A") > > wrote: > > > Arrays are not related to datasets but to variables. It is perfectly acceptable to have multiple arrays dealing with different variables, such as > > > > ARRAYa_array(*) $ var_a1-var_a9; > > > ARRAYb_array(*) var_b1-var_b23; > > > > Different arrays can have different dimensions (9 vs 23 in the example) and types (character vs numeric). > > > > Date9. is a format which has nothing to do with arrays. It only affects how a numeric variable is converted to a character string in the PUT function or the PUT statement. (Date and time variables are just normal numeric variables with special meanings attached to the values.) > > > > -----Original Message----- > > > From: SAS(r) Discussion [mailto:SA...(a)LISTSERV.UGA.EDU] On Behalf Of Sdlentertd > > > Sent: Tuesday, December 15, 2009 11:57 AM > > > To: SA...(a)LISTSERV.UGA.EDU > > > Subject: Re:Arrayuse? > > > > <snip> > > > > This is great and works, but > > > what if one of the fields that has to be inarrayis in different > > > format than the other, for example: ID1 is character but another field > > > is Date which is Date9. and another field Price which is numeric.... > > > How do i put them all in onearray? or how can I do two seperate > > > arrays for one dataset? Thank you- Hide quoted text - > > > > - Show quoted text - > > But the statements bellow do not work > > arraya_ID(*) $ ID1-ID10; (character) > >arrayb_ID(*) ID1-ID10; (numeric) > > Error message: All variables inarraylist must be the same type, > > i.e., all numeric or character.- Hide quoted text - > > - Show quoted text - Thanks Joe Thnaks for taking the time to correct me on SCL lists, they are more powerful then I thought. Showing my ignorance again. Recfm=n does read a fle, but I believe it cannot read a 1gig file as a string, the maximum lrecl=1 megabyte. In PERL you can seemlessly run a regular expression against a file and match a string 1 gigabye into the file.
From: Joe Whitehurst on 18 Dec 2009 12:49 I thought RECFM=N eliminated the construct of LRECL? If the file is rendered recordless, why would there be a maximum LRECL? I'll look a little deeper into this. > Recfm=n does read a fle, but I believe it cannot read a 1gig file as > a string, the maximum lrecl=1 megabyte. > > In PERL you can seemlessly run a regular expression against a file > and match a string 1 gigabye into the file. >
From: xlr82sas on 18 Dec 2009 14:31 On Dec 18, 9:49 am, joewhitehu...(a)GMAIL.COM (Joe Whitehurst) wrote: > I thought RECFM=N eliminated the construct of LRECL? If the file is > rendered recordless, why would there be a maximum LRECL? I'll look a little > deeper into this. > > > > > Recfm=n does read a fle, but I believe it cannot read a 1gig file as > > a string, the maximum lrecl=1 megabyte. > > > In PERL you can seemlessly run a regular expression against a file > > and match a string 1 gigabye into the file.- Hide quoted text - > > - Show quoted text - Hi Joe, I just read an article on SCL lists and they are at least as poweful as you say. I would like to try to use the lists using FCMP from the datastep. Not sure this is possible, but I am looking into it. I think lists are one of the more powerful constructs in SCL. Usually we do not use an lrecl with recfm=n. I tend to consider recfm=n as a one byte at a time stream. However I don't see how SAS can set up to allow functions like prxmatch to search through a 2 gig file to find a match without dealing with 1 megabyte at a tme. It might be interesting to see if recfm=n and a 1 megabyte lrecl will somehow allow SAS to seach the entire 1 megabyte record for a prx macth.
From: xlr82sas on 19 Dec 2009 02:17
On Dec 18, 11:31 am, xlr82sas <xlr82...(a)aol.com> wrote: > On Dec 18, 9:49 am, joewhitehu...(a)GMAIL.COM (Joe Whitehurst) wrote: > > > I thought RECFM=N eliminated the construct of LRECL? If the file is > > rendered recordless, why would there be a maximum LRECL? I'll look a little > > deeper into this. > > > > Recfm=n does read a fle, but I believe it cannot read a 1gig file as > > > a string, the maximum lrecl=1 megabyte. > > > > In PERL you can seemlessly run a regular expression against a file > > > and match a string 1 gigabye into the file.- Hide quoted text - > > > - Show quoted text - > > Hi Joe, > > I just read an article on SCL lists and they are at least as poweful > as you say. I would like to try to use the lists using FCMP from the > datastep. Not sure this is possible, but I am looking into it. > > I think lists are one of the more powerful constructs in SCL. > > Usually we do not use an lrecl with recfm=n. I tend to consider > recfm=n as a one byte at a time stream. However I don't see how SAS > can set up to allow functions like prxmatch to search through a 2 gig > file to find a match without dealing with 1 megabyte at a tme. It > might be interesting to see if recfm=n and a 1 megabyte lrecl will > somehow allow SAS to seach the entire 1 megabyte record for a prx > macth. Hi SAS-Lers, I have receieved some nice offline corrections to my orginal post. One is that lrecl has no effect when recrm=n. I sort of knew that but was trying to somehow get SAS to consider 1 megabyte as a string. I did not want to breakdown the 1 megabyte into 32k chunks. http://support.sas.com/techsup/technote/ts642.html I think the Perl programmers have one up on the SAS programmers because they can treat an entire file as scalar string. If you have pattern that can span multiple lines, you need to read the file as one big scalar. my $data_file = "a.txt"; open DAT, $data_file or die "Could not open file: $!"; my $contents; { local $/ = undef; $contents = <DAT>; } close DAT; my $match; if ($contents =~ YOURPATTERN) { $match = $1; } The regexp searches the entire string contained in $contents (which is the whole file). |