f



Re: How to filter sas data sets into separate sas data sets #2

you cannot do this as described without a common link
here, your Var1

Note: both data sets must be sorted by Var1

Data Newlist (KEEP=node1 node2 node3 ... var15)
     Otherds (Keep=node1 node2 node3 .... var15) ;

do until(EndoFile);

Set SASDS1
    SASDS2 end = EndoFile;
by  Var1;

*consider: if Var1 in (Node1 Node2 Node3);

If    Node1 = VAR1
   or Node2 = VAR1
   or Node3 = Var1
   then Output Newlist ;
Else    Output Otherds ;

end;
stop;

Undoubtedly the HashHeads will propose a lookup table

but the above is what you are trying to do.

Ron Fehd  the macro maven  CDC Atlanta GA USA RJF2 at cdc dot gov

> From: starsoul@mindspring.com
> Listers,
>
> This is my failing point in coding SAS.  The use of 2
> separate SAS data sets to create a third.
>
> I can do this in a program with nested Do loops.  But with
> SAS it is just different enough I seem to be unable to see
> the coding technique.
>
> Problem:
>
> Sas Data set 1 contains 1 variable and 1000 obs.
> Sas Data set 2 contains 15 variables and 500000 obs.
>
> I need to filter off the data in Sas data set 2 based on Sas
> data set 1
>
> Node1, Node2 and Node3 must match VAR1 exactly.  I have all
> the code I need to do this except for splitting the data into
> a separate SAS data set (NEWLISTS).
>
>
> Psuedo code:
>
> Sas Data set 1:  Var1 Length 7 Char
> Sas Data set 2:  Node1 Length 1-8 Char   Node2 Length 1-8
> Char  Node3 Length 1-8 Char
>
>
>
> Data Newlist (KEEP=node1 node2 node3 ... var15)
>      Otherds (Keep=node1 node2 node3 .... var15) ;
>
> Set SASDS1 ;   *Contains 1 var 1000 obs   ;
> Set SASDS2 ;   *Contains 15 vars and 500,000 obs  ;
>
>
> If Node1 = VAR1 or Node2 = VAR1 or Node3 = Var1 then Output
> Newlist ; Else Output Otherds ;
>
>
> I have tried putting in two SET statements, but I seem to
> reduce the information dramatically.  I have been reviewing
> the coding examples on the SAS Wesbsite as well as in the
> archives.  I am just so crunched for time that I must lean on
> you for assistance.
>
> I know this should be easy, I am just not seeing.
0
rjf2 (3342)
4/2/2007 3:20:51 PM
comp.soft-sys.sas 142828 articles. 3 followers. Post Follow

0 Replies
750 Views

Similar Articles

[PageSpeed] 14

Reply:

Similar Artilces:

Re: How to filter sas data sets into separate sas data sets
Lizette, a quick question first: what release of SAS are you using? Seems like an ideal task for a hash solution. Hashes however are only available with SAS version 9. Robert Bardos Ansys AG, Zurich, Switzerland > -----Ursprüngliche Nachricht----- > Von: SAS(r) Discussion > [mailto:SAS-L@LISTSERV.UGA.EDU]Im Auftrag von > Lizette Koehler > Gesendet: Montag, 2. April 2007 16:53 > An: SAS-L@LISTSERV.UGA.EDU > Betreff: How to filter sas data sets into separate sas data sets > > > Listers, > > This is my failing point in coding SAS. The use of 2 > se...

Re: How to filter sas data sets into separate sas data sets #7
Summary: You need a loop and the POINT option or SQL #iw-value=1 Lizette, I think a lot of respondents have misunderstood the problem. This probably could have been avoided with a simplified example. Here is my interpretation. Here is code to generate data. data control ; do var1 = 1 to 4 ; output ; end ; run ; data tosplit ; input node1 node2 node3 other ; cards ; 1 2 3 4 1 2 3 5 7 7 7 7 ; Here is a way to split using the DATA step. data newlist other ; drop flag var1 ; set tosplit ; do pt = 1 to nobs ; set control point = p...

Re: How to filter sas data sets into separate sas data sets #8
On Mon, 2 Apr 2007 23:37:16 +0000, Ian Whitlock <iw1junk@COMCAST.NET> wrote: >Summary: You need a loop and the POINT option or SQL >#iw-value=1 > >Lizette, > >I think a lot of respondents have misunderstood the problem. This probably >could have been avoided with a simplified example. Here is my >interpretation. Here is code to generate data. > > data control ; > do var1 = 1 to 4 ; output ; end ; > run ; > > data tosplit ; > input node1 node2 node3 other ; > cards ; > 1 2 3 4 > 1 2 3 5 > 7 7 7 7 > ; ...

Re: How to filter sas data sets into separate sas data sets #5
Lizette: Can you show (1) your nested do loops that work for you, and (2) some sample data and the data sets that you desire to get? -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Lizette Koehler Sent: Monday, April 02, 2007 9:53 AM To: SAS-L@LISTSERV.UGA.EDU Subject: How to filter sas data sets into separate sas data sets Listers, This is my failing point in coding SAS. The use of 2 separate SAS data sets to create a third. I can do this in a program with nested Do loops. But with SAS it is just different enough I seem to be unable to ...

Re: How to filter sas data sets into separate sas data sets #3
Lizette, Instead of trying to merge the two data sets, I would probably try to create a SAS format from the values of VAR1 in data set 1. Then, NODE1, NODE2 and NODE3 could be compared against the format for a match. The example below is a simplified version of what you could do and shows a printout of how it works. It has 5 observations in data set 1 and only 3 variables in data set 2, but I think the logic should hold for the example you gave. After the example is code that could be used to actually split the data as you had requested. Hope this helps. * create sas data set 1 ; data ...

Re: How to filter sas data sets into separate sas data sets #6
First off, you don't need two set statements, I suspect you want a merge. (remember to sort datasets before merging) Data newlist (KEEP=node1 node2 node3 ... var15) Otherds (Keep=node1 node2 node3 .... var15) ; Merge sasds1 sasds2; By ;/*not sure which variable you need, but there has to be something that is the same between the two*/ What I'd really need to know is what are the field names in DS1 and DS2 (You described them but didn't tell us the names) You will possibly need a REANME= statement to get a matching name to merge by. Either read up more on merges and REN...

Re: How to filter sas data sets into separate sas data sets #4
Something like this is the old way. You could use a proc sql if you have a new enough version. Increase your buffersize and if you have enough memory you may get it into a hash routine. DATA WORK.NEW; MERGE small (IN=A OBS=500) big ; BY ID_FIELD; IF A=1; RUN; QUIT; RICH -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@listserv.vt.edu] On Behalf Of Lizette Koehler Sent: Monday, April 02, 2007 10:53 AM To: SAS-L@LISTSERV.VT.EDU Subject: How to filter sas data sets into separate sas data sets Listers, This is my failing point in coding SAS. T...

How to filter sas data sets into separate sas data sets
Listers, This is my failing point in coding SAS. The use of 2 separate SAS data sets to create a third. I can do this in a program with nested Do loops. But with SAS it is just different enough I seem to be unable to see the coding technique. Problem: Sas Data set 1 contains 1 variable and 1000 obs. Sas Data set 2 contains 15 variables and 500000 obs. I need to filter off the data in Sas data set 2 based on Sas data set 1 Node1, Node2 and Node3 must match VAR1 exactly. I have all the code I need to do this except for splitting the data into a separate SAS data set (NEWLISTS). Psuedo...

Re: How to filter sas data sets into separate sas data s ets
I think that both Ron's (as he mentioned) and Richard solutions require that VAR1 is in both datasets. But from the original post, it seemed to me that VAR1 is only in data set 1, and it must be matched to 1 of 3 variables in data set 2 (NODE1, NODE2 or NODE3) to be output to the NEWLIST data set. For this reason, I think a format is one possible approach. Maybe the original poster can clarify this point. Thanks. Jack Clark Research Analyst Center for Health Program Development and Management University of Maryland, Baltimore County -----Original Message----- From: SAS(r) Discussio...

Re: search SAS data set from SAS code #2
Rose, The answer to your question depends on your operating system. In Windows, there's the Search tool. In Unix/Linux, you can use grep Bob Abelson HGSI 240 314 4400 x1374 bob_abelson@hgsi.com Rose <myr_rose@YAHOO.COM> Sent by: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> 04/19/2005 11:13 AM Please respond to myr_rose To: SAS-L@LISTSERV.UGA.EDU cc: Subject: search SAS data set from SAS code Hi All, Suppose I have a sas permanent data set which was created early, I know the library path but I couldn't remember in which s...

Re: Exporting a SAS data set to Text file on SAS unix #2
You could try PROC EXPORT instead of the datastep... it should work to export a comma-delimited file. But Mike's suggestion will work well, and might be more flexible for you - and is not dissimilar to what PROC EXPORT actually physically does, I suspect. -Joe On Tue, Feb 2, 2010 at 3:48 PM, Ranjhana <ranjhanas@gmail.com> wrote: > Hi All, > > I used the following code to export a SAS dataset to text file, but i > am unable to get the header. Can anybody tell me how to get the header > (Variable names) to the text file ? > > Filename out "/home/z19/test_e...

Re: Reading & Writing SAS data sets without SAS #2
On Mon, 27 Jul 2009 14:03:58 -0400, Philip Rack <PhilRack@MINEQUEST.COM> wrote: .... >I was out on Alan Churchill's blog and noticed that he's able to read AND >write SAS data sets now without using SAS. Rather interesting... > >http://savian.blogspot.com/ .... Hi, It must be incredibly difficult, but this has been done -- Stat/Transfer has been able to read and write SAS datasets. I hope SI makes .sas7bdat and related proprietary binary file formats open and documented. It's been a while they replaced the version 6 binary files (.sd2, and so forth), and should be...

Re: Reading SAS data sets on UNIX by non-SAS apps #2
John: Following on Richard's thoughtful suggestions, the Affinium system would likely capture data from csv files. SAS PROC EXPORT produces them quickly, and loading them into external systems works faster for relatively basic data structures and data formats, in my experience, than xml parsing. Sig -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of John Bentley Sent: Monday, October 18, 2004 10:10 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Reading SAS data sets on UNIX by non-SAS apps I have SAS data sets on AIX that we need to read with Unica&#...

Re: Modifying SAS Data Sets in the SET command #2
Hi Sober (do you have a real name?) - Looks good, but you can't perform an assignment function in a set statement whereas you can use a function in a where comparison. Where clauses are processed before the data is read into the data vector, so generally for tables with many variables, where processing can save substantial IO overhead. 1 data A; 2 col1='2003'; 3 col2='a'; 4 col3='b'; 5 col4='c'; 6 output; 7 8 NOTE: The data set WORK.A has 1 observations and 4 variables. NOTE: DATA statement used: real time 0.0...

Re: XML data to SAS data set converstion #2
A correction. The initial post asked: "Is it possible to convert an XML data to SAS data set without a SAS environment?" If there is no SAS at all in a particular shop, then there is no way to do this conversion. If access to SAS is available via IOM then there are ways. What "environment" means becomes the question. If a shop can simply convert into a compatible SAS XML format that is a possibility. The other is to convert it into a delimited file or get it into a database that a SAS shop can read. The SAS dataset layout is binary and unknown. You could put it into a S...

Re: search SAS data set from SAS code
> From: Rose > Hi All, > Suppose I have a sas permanent data set which was created > early, I know > the library path but I couldn't remember in which sas program code I > created it. how can I search from so many sas program files in > different folders and find it. a problem familiar to all of us delayed-housekeeping folks. Libname Libref '<directory-specification>'; DATA LibRef.DataSetName; use your system utilities to search for the dir-spec of your libref. search: *.sas containing text: <dir-spec> once you have found the libname...

Re: Compressing data sets (was Re: [SAS-L]) #2 #2
Yes, but that's still having another program do the decompression on your behalf. -- JackHamilton@FirstHealth.com Manager, Technical Development Metrics Department, First Health West Sacramento, California USA >>> <ben.powell@CLA.CO.UK> 01/06/2004 1:21 AM >>> On Mon, 5 Jan 2004 18:14:02 -0700, Jack Hamilton <JackHamilton@FIRSTHEALTH.COM> wrote: >OK, "you or a program on your behalf will have to decompress them before >use". > > > >-- >JackHamilton@FirstHealth.com >Manager, Technical Development >Metrics Department, Fir...

Re: Create SAS dataset from C# data table or data set #2
Download the SAS OleDb driver (free) and use the following code: private static DataTable LoadSasDataSet() { try { string library = prop.Default.SasLibrary ; string dataset = prop.Default.SasDataset; DataSet sasDs = new DataSet(); OleDbConnection sas = new OleDbConnection("Provider=sas.LocalProvider; Data Source=" + library); sas.Open(); OleDbCommand sasCommand = sas.CreateCommand(); sasCommand.CommandType = CommandType.TableDirect;...

Re: search SAS data set from SAS code #5
Rose, You have some good advice on search techniques, but they may beinadequate. I hope your LIBNAME wasn't something like libname lib "&dir" ; Perhaps you should also search for ".member", but that also couldhave the same problem. You might also look for key variablenames or values, or procedures that you know created the data.The date from a PROC CONTENTs might provide useful information,or an old report created by the same program with a footnote,"Source code: ...". Maybe data lib.w ( label="created by ..." ) ; would be a good habit to ...

Re: search SAS data set from SAS code #4
Look at Google Desktop as well. Very fast. Thanks, Alan Savian "Bridging SAS and Microsoft Technologies" -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Harry Droogendyk Sent: Tuesday, April 19, 2005 8:23 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: search SAS data set from SAS code Most O/S have a search feature, eg. Windows has search/find command off Start button, will look inside files for a string, eg. our libname / directory. Ultraedit has a handy search feature as well. On 'NIX, you'll use grep, mainframe, 3.something...

Re: search SAS data set from SAS code #6
Rose In addition to the search tools that have been mentioned, the following program will search ONE directory and dump all of the SAS programs to a single flat file. The boundaries of each program are flagged and the source identified. This file may then be searched with a text editor and you will be able to see the associated lines of code. Old big-iron geeks may notice a resemblance to Proc Source which produces similar output. I have tried running this with a wild card in place of a folder name but that does not work. Nat Wooding dm 'log;clear;output;clear;pgm;'; ** note that t...

Re: search SAS data set from SAS code #3
Most O/S have a search feature, eg. Windows has search/find command off Start button, will look inside files for a string, eg. our libname / directory. Ultraedit has a handy search feature as well. On 'NIX, you'll use grep, mainframe, 3.something. Consider putting the program name in the data set label ( which shows up in CONTENTS ) at creation time to better keep track of this type of thing. data libname.mydata ( label = "Created by pgm" ); ... run; -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of Rose Sent: Tuesday, Ap...

Convert SAS data set to an SPSS data set
I am trying to convert a SAS data set to na SPSS data set. I tried to use PROC EXPORT with DBMS = sav; but SAS is telling me that is not a valid for export. So how do I convert my SAS data set to a SPSS file? Any help is welcomed. On Apr 7, 4:52=A0pm, cwgmath <cwgmath1...@yahoo.com> wrote: > I am trying to convert a SAS data set to na SPSS data set. =A0I tried to > use PROC EXPORT with DBMS =3D sav; but SAS is telling me that is not a > valid for export. =A0So how do I convert my SAS data set to a SPSS > file? =A0Any help is welcomed. Try DBMS=3DSPSS instead of...

Re: Exporting a SAS data set to Text file on SAS unix
hi ... you can try this (I changed your data set a bit) ... * variable names into a macro variable (tab separated); proc sql noprint; select name into :vars separated by '09'x from dictionary.columns where libname eq 'SASHELP' and memname eq 'CLASS' order varnum; quit; data _null_; file 'z:\class.txt'; * write the variable names; put "&vars"; file 'z:\class.txt' dsd dlm='09'x ; * write the variable values; do until (done); set sashelp.class end=done; put (_all_) (:); end; stop; run; -- Mike Zdeb U@Albany School of Public ...

Web resources about - Re: How to filter sas data sets into separate sas data sets #2 - comp.soft-sys.sas

Separate Baptists - Wikipedia, the free encyclopedia
... but its sources remain unclear because it lacks inline citations . Please improve this article by introducing more precise citations. The Separate ...

REPORT: Facebook at Work Website Closer to Launch; Personal Timelines to Be Kept Separate
... Times reported Sunday that the new site will contain much of the same functionality as Facebook, but it will keep personal Timelines separate ...

Facebook tests ‘Pages Feed’ so fans can see all updates in separate stream
Some Facebook users are seeing a separate “ Pages Feed ” where they can view all the updates from pages they Like in a single stream. This seems ...

Startup Founders and Entrepreneurs : What separates the top 10% of startup CEOs from the rest?
Answer (1 of 55): I've interviewed thousands of CEOs and some things that stand out to me: 1. Good at hiring AND firing. Whenever you find a ...

J is for Jettison, how Orion safely separates its elements during space flight. - Flickr - Photo Sharing ...
Once Orion reaches orbit, its Launch Abort System is jettisoned or discarded, releasing the spacecraft into space. Prior to re-entry, the service ...

Journey-Separate Ways performed by Recess - YouTube
This video was featured on Yahoo.com's front page April 18, 2009. It was the kids first gig together, video has received over 735,000 views on ...

Two men fight for life after separate stoushes
Police are speaking with a man who has volunteered himself to Petrie officers after a violent night on Brisbane's streets.

Orica to separate chemical arm
Group eyes potential $1bn demerger as it narrows focus on mining services business.

Two killed in separate crashes
... woman has been killed after she was hit by a truck in Melbourne's south-east. Two people, including an elderly woman, have been killed in separate ...

One toddler dead and another critical after separate Sydney backyard pool incidents - DailyTelegraph ...
A MOTHER is grieving after losing her baby boy to a tragic backyard incident in Western Sydney yesterday.

Resources last updated: 2/18/2016 9:47:31 AM