BookmarkSubscribeRSS Feed
reone
Calcite | Level 5
Sorry to all if I wasn't clear before,

yes i need to compare the observations with ALL subsequent observations!

reone.
Peter_C
Rhodochrosite | Level 12
if it is each obs with all subsequent, then data step is going to need more trouble (set with point) than sql _probably_
Contrast the management of arrays (remembering the probable need for two - one nums other chars) with sql using select column name++ into :host_variable over all columns required for compare, to generate the select statement defining columns out of the sql compare. Even though sql doesn't have the equivalent of the _n_ in data steps, it is easy to generate for the sql join filter[pre] where A_n_ > B_n_ [/pre]with datastep view like[pre]data a/view=a ;
A_n_ +1;
set &input_data_set ;
run ;
data b/view=b ;
B_n_ +1 ;
set &input_data_set ;
run ; [/pre]Then code needs to be generated to create the required outcome. Perhaps it would be enough to generate something like[pre] select A_n_, B_n_, (a.name = B.name ) as d_name [/pre]where I hope "name" and its prefixes A., B. and D_ are indicative enough. The ( compare) part is repeated for each variable name in &input_data_set so proc contents out= or dictionary.columns would be used to retrieve that list of names as "data".
This is clearly creating a lot of output data, not just a lot of coding trouble. Before investing more time - are you sure this is productive? Would you like to explain how this is useful to you?

peterC
reone
Calcite | Level 5
Thanks, Peter.C
I have followed your advice, about to compare each record with ALL record in SQL and it works fine. Yes, I need to use this solution for my program.

Thanks
reone.
FloydNevseta
Pyrite | Level 9
Why don't you sort the data by cod and mounth, so the info is grouped by cod? Then you process the sorted dataset with a BY.

Am I mssing something here?

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 18 replies
  • 3793 views
  • 0 likes
  • 7 in conversation