BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ksharp
Super User

Hi , Patrick and PGStat.

I figure out another Hash solution without pre-sorting dataset .I think it will be faster than your SQL.

Just Guess. Smiley Happy

proc import datafile='d:\software\SampleFile.xls' out=have dbms=excel replace;
getnames=yes;run;
data have(drop=_f);
 set have(rename=(filldat=_f));
 filldat=input(_f,mmddyy10.);
 format filldat mmddyy10.;
run;

proc sql noprint;
 select quote(name) into : list separated by ','
  from dictionary.columns
   where libname='WORK' and memname='HAVE';
quit; 
data _null_;
if _n_ eq 1 then do;
declare hash ha1();
declare hiter hi1('ha1');
declare hash ha2();
 ha1.definekey('_year','_qtr');
 ha1.definedata('_year','_qtr','ha2');
 ha1.definedone();
end;
 set have end=last;
 _year=year(filldat);_qtr=qtr(filldat);
 if ha1.find()=0 then ha2.add();
  else do;
        ha2=_new_ hash(multidata:'Y');
        ha2.definekey('_year','_qtr');
        ha2.definedata(&list);
        ha2.definedone();
        ha2.add();
        ha1.add();
      end;
 if last then do;
                do while(hi1.next()=0);
                  ha2.output(dataset: cats('Q',_qtr,'_',_year));
                end;
              end;
run;



Ksharp

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 15 replies
  • 5596 views
  • 2 likes
  • 7 in conversation