| Date: | Fri, 26 Nov 2010 19:15:14 +0000 |
| Reply-To: | "Keintz, H. Mark" <mkeintz@WHARTON.UPENN.EDU> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Keintz, H. Mark" <mkeintz@WHARTON.UPENN.EDU> |
| Subject: | Re: $varying9. and strange input statement |
|
| In-Reply-To: | <001d01cb8d9c$66a62450$33f26cf0$@com> |
| Content-Type: | text/plain; charset="us-ascii" |
Max:
Yes it's "sloppy", and not the only example.
That's why SAS should be viewed as a tool that looks a lot like a language. It's a successful approach as long as the tool is useful and flexible. IMO, SAS is both and, generally speaking, becoming more so.
Regards,
Mark
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> bbser2009
> Sent: Friday, November 26, 2010 2:02 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: $varying9. and strange input statement
>
> Art and Jack
>
> Consider two input statements to read the character data value
> 3sunfish:
> 1. input x 1. name $varying9. x;
> 2. input x 2. name $9. x;
>
> As you mentioned,
> 1) in the first input statement, SAS treats the second x as the d
> value,
> namely, the decimal part of the informat $varying9.
> 2) But for the second input statement, SAS seemly tries to read another
> numeric value for the second x, so we actually ended up with a missing
> value
> for x in the output.
>
> This is really a sloppy grammar. Any comments, please?
>
> Max
>
>
> -----Original Message-----
> From: Jack F. Hamilton [mailto:jfh@alumni.stanford.org]
> Sent: November-26-10 1:22 PM
> To: bbser2009
> Cc: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: [SAS-L] $varying9. and strange input statement
>
> The example you show below is straight out of the documentation:
>
>
> <http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a000193602.h
> tm>
>
> You should send email to support@sas.com asking them to improve the
> documentation if you don't think it's sufficient. I agree that the
> documentation is a bit murky, but working through the two examples
> should
> make it clear.
>
> "input x 1." reads "3" from the input line and stores it as the number
> 3 in
> the variable X.
>
> "name $varying9. x" reads the next portion of the input line into
> variable
> NAME. How much does it read? The number of characters specified in
> variable X. You just set the value of X to 3, so it reads 3
> characters. If
> x equals 3, then "$varying9. x" reads 3 characters. If x equals 8,
> "$varying9. x" reads 8 characters.
>
>
>
>
> On Nov 26, 2010, at 9:55 , bbser2009 wrote:
>
> > Here are two questions about the code below:
> > 1. Why the value for the variable name is the string "sun" instead of
> > "sunfish"?
> > 2. What's the purpose for listing the second x in the input
> statement?
> >
> > Thanks. Max
> >
> > data temp;
> > input x 1. name $varying9. x;
> > cards;
> > 3sunfish
> > ;
> > proc print;
> > run;
> >
> > Result of this code:
> >
> > obs x name
> > 1 3 sun
|