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 2001, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 18 Jan 2001 04:45:11 -0000
Reply-To:     sashole@bellsouth.net
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Paul Dorfman <paul_dorfman@HOTMAIL.COM>
Subject:      Re: 3 Questions.
Comments: To: giuliobelrango@HOME.COM
Content-Type: text/plain; format=flowed

>From: Giulio Belrango 1) When using >PROC PRINT NOOBS N; N gives you the total number of observations as N=999 >Can N be labeled or over ridden to be 'TOTAL' or 'COUNT' as an example ie >from N=999 to Total=999

Nope.

>2) How can I PROC PRINT; selectively based on a variable from a prievous >step ie Data Stuff; A=1; B=2; If B=3 then Proc print;

data stuff; a=1; do b=1 to 3,3,3, 4 to 5; output; end; run; proc print data=stuff; where b = 3; run;

>3) I'm using an array statement and trying to output the statement. Array >dall(30) dall1-dall30; When I output the array ie file out; do i=1 to 30; >dall(i)='Hi'; end; put @ 1 stockno $char10. @11 description $char50. @61 >dall1-dall30; if outputs like this 1111111111A TOOL Hi Hi Hi Hi Hi ..... >etc for 30 times The 'Hi' has a built in space in between each occurances. >SAS seems to put a space in between each occurance. I'd like the output to >be without the space. 1111111111A TOOL HiHiHiHiHiHi .....etc for 30 times >I've tried Array dall2(30) dall-dall30; do i=1 to 30; >dall2(i)=trim(dall(i)); end; Then outputing and I get the same thing.

First of all, the compiler will have a type contention. If you had defined

Array dall(30) $1 dall1-dall30;

you would have told the compiler that dall1-dall30 are all character variables, 1 byte long. But you ahve defined

Array dall(30) $2 dall1-dall30;

It means that dall1-dall30 are *numeric* variables, and since it is the first statement in the step, this is ow the compiler stores this variables in the symbol table. Now when you code

dall(i)='Hi';

you are changing the story by telling him (the compiler is a male) that the DALL variables are character. He cannot stomach it and vomits on the log:

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column). 18:5 NOTE: Invalid numeric data, 'Hi' , at line 18 column 13.

Now imagine for a second that you have defined the array properly as $2. Then you observation about the embedded space is true, but you can easily fight it. Just print the variables as either of the lists

put (dall(*)) ($2.); put (dall1-dall30) ($2.) ;

The former is good only if DALLs are array-incorporated; the latter is array-free. The 'Hi's end up adjacent because of the exact format specification. If you *need* a space, use $3.; if you need 2 spaces, use $4., and so forth.

Kind regards, ======================= Paul M. Dorfman Jacksonville, Fl =======================

>Any suguestions? _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com


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