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 (August 2004, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 10 Aug 2004 15:49:04 -0400
Reply-To:   Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject:   Re: Two basic SAS datastep questions but very urgent!

If just a list of Zip codes is needed (no counts), the SQL statement could be as simple as

select distinct zipcode from test;

On Mon, 9 Aug 2004 09:32:39 -0400, ben.powell@CLA.CO.UK wrote:

>To mark specific records you could use a flag, i.e set variable flag = 1 or >0 depending whether it is one of your select values or not. > >For instance, > >data test; >set test; >if _N_ in(7 90 100 101 103 400 523 633 635 800) then flag = 1;/*OR USE >ANOTHER METHOD TO SELECT THE RECORDS, FOR INSTANCE IF THEY ARE IN A CERTAIN >RANGE.*/ >else flag = 0; >run; > >data subset; >set test; >if flag = 1; >run; > >or > >proc freq data = test (where=(flag=1));table zipcode;run; > >Incidentally, the final suggestion above will solve your second problem and >give you a distinct list of all zipcodes should you remove the where >clause. Alternatively you could create an output dataset: > >proc freq data = test; >table zipcode / out = tf; >run; > >Alternatively, try sql: > >proc sql; >create table z_count as >select distinct zipcode, count(*) as qty >from test >group by zipcode; >quit; > >HTH. > >On Sat, 7 Aug 2004 13:19:08 -0700, Se Yan <laseyan@GMAIL.COM> wrote: > >>1. Is there any method in SAS that can mark some specific records in >>my dataset? I have a dataset with 10000 records, but i have ten >>records that are special and need to be marked, so that in the further >>procedures I can choose to include or exclude these records, but i >>don't want to split the dataset into two files. How can I do that? >> >>2. I have 10000 individual records, but there is a variable "zipcode", >>which only has 500 different values, i.e, average 20 persons per >>zipcode in the dataset. Which command can give me the list of these >>500 different values of zipcodes? >> >>I know the problems are quite basic. BUt i madly need help!


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