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 (January 2007, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 7 Jan 2007 00:50:34 -0500
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: Help with formatting dataset.
Comments: To: SAS-L Nirmal <lazybone2k@GMAIL.COM>

Nirmal wrote to me, off-line, indicating that I had misunderstood the question.

>Thanks for the reply, but A1,B1, B2, C1.....are various values of the >variables...i used A1, B1, as to explain the levels of the >variables. It can be anything. I want to create a dataset which contains >the levels of the variables ....just as i mentioned in the earlier >post.....for example the input dataset contains 1 market, 2 buyer, 4 >products and 2 types in their original the output dataset >shown below explains the various levels of the variables in numbers, ---- >market has 1 level, buyer has 2 levels, .....

In that case, I would use proc sql. For example:

data have; input Market $ Buyer $ Product $ Type $; cards; A1 B1 C1 D1 A1 B1 C1 D2 A1 B1 C2 D1 A1 B1 C2 D2 A1 B1 C3 D1 A1 B1 C3 D2 A1 B1 C4 D1 A1 B1 C4 D2 A1 B2 C1 D1 A1 B2 C1 D2 A1 B2 C2 D1 A1 B2 C2 D2 A1 B2 C3 D1 A1 B2 C3 D2 A1 B2 C4 D1 A1 B2 C4 D2 ; run;

proc sql; create table want as select count(distinct Market) as Market, count(distinct Buyer) as buyer, count(distinct Product) as Product, count(distinct Type) as Type from have; quit;

Art -------- On Sat, 6 Jan 2007 20:01:11 -0500, SAS-L Nirmal <lazybone2k@GMAIL.COM> wrote:

>Dear SAS-l users, >I have a dataset which contains 4 vaiables. The sample data sets looks >like this >Market Buyer Product Type >A1 B1 C1 D1 >A1 B1 C1 D2 >A1 B1 C2 D1 >A1 B1 C2 D2 >A1 B1 C3 D1 >A1 B1 C3 D2 >A1 B1 C4 D1 >A1 B1 C4 D2 >A1 B2 C1 D1 >A1 B2 C1 D2 >A1 B2 C2 D1 >A1 B2 C2 D2 >A1 B2 C3 D1 >A1 B2 C3 D2 >A1 B2 C4 D1 >A1 B2 C4 D2 > >and i want to format this dataset into something like this. > >Market Buyer Product Type >1 1 1 1 >1 1 1 2 >1 1 2 1 >1 1 2 2 >1 1 3 1 >1 1 3 2 >1 1 4 1 >1 1 4 2 >1 2 1 1 >1 2 1 2 >1 2 2 1 >1 2 2 2 >1 2 3 1 >1 2 3 2 >1 2 4 1 >1 2 4 2 > >The problem is i cannot hard code the format values. I did quite some work >on this(i am not lazy!!!!!)...i counted the various variables and the >levels and used a do loop to construct the output. But its not working. I >also tried proc format. But i want to write a program which is data >driven. It shud read the values and construct this. I would really >appreciate any suggestions or tips on this one. Thanks again. > >regards, >Nirmal

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