BookmarkSubscribeRSS Feed
ajay35
Calcite | Level 5

 

data abx;
infile datalines dlm=" ";
input name :$20. score1 score2 score3;
datalines;;
a 23 23 23
b 23 12 12
c 23 45 66
a 66 88 99
c 34 66 45
;
run;


proc sql;
select distinct name,quote(name)
into :k separeted by " ",
:j separeted by ","
from abx;
quit;


option mprint;
data &k;
set abx;
array d[*] &k ;//here i did  small change it is taking array but it did not send s out put  to assigned data set please help//
do i=1 to dim(d) ;
if d[i]=name then output d[i];
end;
run;

 

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
70
71
72
73 data abx;
74 infile datalines dlm=" ";
75 input name :$20. score1 score2 score3;
76 datalines;
 
NOTE: The data set WORK.ABX has 5 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 523.06k
OS Memory 27048.00k
Timestamp 08/02/2018 12:17:28 PM
Step Count 30 Switch Count 2
Page Faults 0
Page Reclaims 168
Page Swaps 0
Voluntary Context Switches 9
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264
 
76 ! ;
82 ;
 
83 run;
84
85
86 proc sql;
87 select distinct name,quote(name)
88 into :k separeted by " ",
_________
1
89 :j separeted by ","
_________
1
WARNING 1-322: Assuming the symbol SEPARATED was misspelled as separeted.
 
90 from abx;
91 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 5448.37k
OS Memory 32172.00k
Timestamp 08/02/2018 12:17:28 PM
Step Count 31 Switch Count 0
Page Faults 0
Page Reclaims 686
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 8
 
 
92
93
94 option mprint;
95 data &k;
96 set abx;
97 array d[*] &k ;
98 do i=1 to dim(d) ;
99 if d[i]=name then output d[i];
_
22
76
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, ;, RC, _DATA_, _LAST_, _NULL_.
 
ERROR 76-322: Syntax error, statement will be ignored.
 
100 end;
101 run;
 
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
99:9
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.A may be incomplete. When this step was stopped there were 0 observations and 8 variables.
WARNING: The data set WORK.B may be incomplete. When this step was stopped there were 0 observations and 8 variables.
WARNING: The data set WORK.C may be incomplete. When this step was stopped there were 0 observations and 8 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 1311.81k
OS Memory 29364.00k
Timestamp 08/02/2018 12:17:28 PM
Step Count 32 Switch Count 6
Page Faults 0
Page Reclaims 258
Page Swaps 0
Voluntary Context Switches 27
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 792
 
 
102
103 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
115
 
 
 
7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

The warning and error tell you what you need to know. 

1) You have mispelt separated.

2) there needs to be speace before _character_ and after it.

 

After that however, it really doesn't make sense to me why you are doing this in the first place?  The logic is all wrong, _character_ will select all the variables in the dataset with character format, your select into macro step is selecting all variables in the dataset, overlap at the best of times, errors most of the time.  Explain what it is your trying to do, show what you want out.  For instance, you could forget all that code, and to proces the score data - which is numeric by the way, so _character_ will not work - you can simply do:

data want;
  set abc;
  array score{3};
  do i=1 to 3;
    ...;
  end;
run;

Looking further your using the output statment incorrectly as well, and comparing name to nothing.  As above, post what you want to do and show some output so that we can guide you properly.

ajay35
Calcite | Level 5
i want create n data set with the name using single data set then thought this might be works in that scenario i tried but it shows 2 errors in sending observation to the output .
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, I don't follow.  Try showing what the output should be from your test data.

ajay35
Calcite | Level 5
Hi i will explain detail .
For example you have basket in that basket you have diffrent color boxes.
Blue ,red , white and green
Now i want to divide balls into diffrent color baskets like blue in blue,red in red like this I want
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, without a clear cut example can't provide anything.  What I would say is that what you are doing is called "binning" the data.  There are numerous papers out there and several different methods.  For example one way would be to normalise the data - i.e. instead of going across, have all the data going down, and then use something like proc rank:

http://documentation.sas.com/?docsetId=proc&docsetTarget=p0le3p5ngj1zlbn1mh3tistq9t76.htm&docsetVers...

Or apply the logic yourself in a datastep.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1100 views
  • 0 likes
  • 2 in conversation