DATA Step, Macro, Functions and more

setting two dataset

Accepted Solution Solved
Reply
Contributor
Posts: 52
Accepted Solution

setting two dataset

hello all,

when I am setting two dataset by following codes, the results shows,

NOTE: Data file P.PUBLIC2.DATA is in a format that is native to another host, or the
      file encoding does not match the session encoding. Cross Environment Data Access will be
      used, which might require additional CPU resources and might reduce performance.
30   data Step2.PublicationsNew ;
31   SET P.PUBLICATION1 P.PUBLICATIONS2 ;
NOTE: Data file P.PUBLICATIONS2.DATA is in a format that is native to another host, or the
      file encoding does not match the session encoding. Cross Environment Data Access will be
      used, which might require additional CPU resources and might reduce performance.
32   BY pat_publn_id ;
33   run;

ERROR: BY variables are not properly sorted on data set P.PUBLICATIONS2.
pat_publn_id=900093015 publn_auth=JP publn_nr=1174460 publn_nr_original=  publn_kind=A
appln_id=930063756 publn_date=9999-12-31 publn_lg=  publn_first_grant=0 publn_claims=0
FIRST.pat_publn_id=1 LAST.pat_publn_id=0 _ERROR_=1 _N_=98685272
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 98685270 observations read from the data set P.PUBLICATION1.
NOTE: There were 4 observations read from the data set P.PUBLICATIONS2.
WARNING: The data set STEP2.PUBLICATIONSNEW may be incomplete.  When this step was stopped there
         were 98685271 observations and 10 variables.
WARNING: Data set STEP2.PUBLICATIONSNEW was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           57:16.16
      cpu time            1:07.79

what should I for it, could you please give me some suggestion ?, in particular, the data set P.PUBLICATION1 has 100491569 observations, but only 98685270 observations read from the data set P.PUBLICATION1 in this process. besides, there is a note, which is

Data file P.PUBLICATIONS2.DATA is in a format that is native to another host, or the
      file encoding does not match the session encoding. Cross Environment Data Access will be
      used, which might require additional CPU resources and might reduce performance.

is it the problem ? Thanks in advance.


Accepted Solutions
Solution
‎05-13-2018 11:38 AM
Trusted Advisor
Posts: 1,848

Re: setting two dataset

When you use BY statement sas assumes that the file is sorted already.

As you have two input files both have to sorted then you need merge instead set.

 

Your inut dataset is probably created in other OS than the current one. 

Sas notes it but knows how to deal wih it.

 

Your code should include sort preceding your step:

proc sort data=P.PUBLICATION1;
   BY pat_publn_id ;
run;
proc sort data=P.PUBLICATIONS2;
   BY pat_publn_id ;
run;

data Step2.PublicationsNew ;
  merge P.PUBLICATION1
             P.PUBLICATIONS2 ;
   BY pat_publn_id ;
run;

View solution in original post


All Replies
Solution
‎05-13-2018 11:38 AM
Trusted Advisor
Posts: 1,848

Re: setting two dataset

When you use BY statement sas assumes that the file is sorted already.

As you have two input files both have to sorted then you need merge instead set.

 

Your inut dataset is probably created in other OS than the current one. 

Sas notes it but knows how to deal wih it.

 

Your code should include sort preceding your step:

proc sort data=P.PUBLICATION1;
   BY pat_publn_id ;
run;
proc sort data=P.PUBLICATIONS2;
   BY pat_publn_id ;
run;

data Step2.PublicationsNew ;
  merge P.PUBLICATION1
             P.PUBLICATIONS2 ;
   BY pat_publn_id ;
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 160 views
  • 0 likes
  • 2 in conversation