Date: Fri, 21 Dec 2001 13:02:04 -0500
Reply-To: Edward Heaton <HEATONE@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Edward Heaton <HEATONE@WESTAT.COM>
Subject: Re: Count char var with wildcards (was Frequencies given Conditio
ns on Char Variable)
Content-Type: text/plain; charset="iso-8859-1"
Mark,
The syntax for a WHEN statement is
When ( condition ) action ;
You seemed to code
when (index(statcode,'__4__')) > 0 gestalt = 'xx4xx';
If we match this to the syntax, we get the condition to be
index(statcode,'__4__')
and the action to be
> 0 gestalt = 'xx4xx'
See your error? You should have coded
When ( index( statCode , "__4__" ) > 0 ) gestalt = "xx4xx" ;
Hope this helps,
Ed
Edward Heaton, Senior Systems Analyst,
Westat (An Employee-Owned Research Corporation),
1550 Research Boulevard, Room 2018, Rockville, MD 20850-3195
Voice: (301) 610-4818 Fax: (301) 294-3992
mailto:EdwardHeaton@westat.com http://www.westat.com
-----Original Message-----
From: Mark Moran [mailto:mark.k.moran@CENSUS.GOV]
Sent: Friday, December 21, 2001 10:05 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Count char var with wildcards (was Frequencies given Conditions
on Char Variable)
I used Ya Huang's dataset, except that I am calling the variable statcode.
Below is the dataset code, followed by the errors in the log for later SAS.
Mark
data xx;
input statcode $;
cards;
12345
12435
21456
32525
23426
00324
34320
00003
34526
45736
34637
56823
;
NOTE: SAS initialization used:
real time 6.33 seconds
cpu time 1.25 seconds
NOTE: AUTOEXEC processing completed.
1
2
3
4 data xx;
5 input statcode $;
6 cards;
NOTE: The data set WORK.XX has 12 observations and 1 variables.
NOTE: DATA statement used:
real time 0.39 seconds
cpu time 0.05 seconds
19 ;
20
21 Data temp;
22 set xx;
23 length gestalt $ 5;
24 select;
25 when (index(statcode,'__4__')) > 0 gestalt = 'xx4xx';
-
180
26 when (index(statcode,'___2_')) > 0 gestalt = 'xxx2x';
-
180
27 when (index(statcode,'0000_')) > 0 gestalt = '0000x';
-
180
28 otherwise gestalt = .;
29 end;
30 run;
ERROR 180-322: Statement is not valid or it is used out of proper order.
NOTE: Numeric values have been converted to character
values at the places given by: (Line):(Column).
28:25
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TEMP may be incomplete. When this step was
stopped there were 0 observations and 2 variables.
NOTE: DATA statement used:
real time 0.29 seconds
cpu time 0.05 seconds