03-25-2015 02:56 PM
input name $ score1 score2 score3 team $;
Joe 11 32 76 red
Mitchel 13 29 82 blue
Susan 14 27 74 green
data scores1 scores2;
if name="Joe" then output scores1;
NOTE: There were 3 observations read from the data set WORK.SCORES.
NOTE: The data set WORK.SCORES1 has 3 observations and 5 variables.
NOTE: The data set WORK.SCORES2 has 2 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
I was using this article from SAS community
Example for Conditionally Writing Observations to Multiple Data Sets
One of the SAS data sets contains tours that are guided by the tour guide Lucas and the other contains tours led by other guides. Writing to multiple data sets is accomplished by doing one of the following: 1 naming both data sets in the DATA statement. 2 selecting the observations using an IF condition 3 using an OUTPUT statement in the THEN and ELSE clauses to output the observations to the appropriate data sets
The following DATA step shows these steps:
options pagesize=60 linesize=80 pageno=1 nodate;
data lucastour othertours; set mylib.arts; if TourGuide = ’Lucas’ then output lucastour; else output othertours;
proc print data=lucastour; title "Data Set with TourGuide = ’Lucas’"; proc print data=othertours; title "Data Set with Other Guides"; run;
The following output displays the results:
Output 10.7 Creating Two Data Sets with One DATA Step Data Set with TourGuide = ’Lucas’ 1 Land Tour Obs City Nights Cost Budget Guide 1 Paris 8 1680 High Lucas 2 New York 6 . Lucas Data Set with Other Guides 2 Land Tour Obs City Nights Cost Budget Guide 1 Rome 3 750 Medium D’Amico 2 London 6 1230 High Wilson 3 Madrid 3 370 Low Torres
03-25-2015 03:27 PM
Exactly. What needs going to 'score1' go to 'score1', what shouldn't go to 'score1' still go to 'score1'; while for 'score2', it is different story . What shouldn't go to 'score2' stop at 'score1'.
Need further help from the community? Please ask a new question.