BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PierreYvesILY
Pyrite | Level 9

hello,

 

I used the recommended code and it worked perffecly well.

 

I now have to treat other problems.

 

thanks a lot

PY

koyelghosh
Lapis Lazuli | Level 10

@PierreYvesILY Is it possible for you to be more specific by giving examples of input data and the expected outcomes? There may or may not be an easy way out but until a more concrete example is seen it is hard to suggest. You may just stick to one month, "Month N/Structure/Data 1..x".

 

PierreYvesILY
Pyrite | Level 9

hello, thanks for responding.

 

Here is the final type of outcome:

 

SAS_#Board_StructureBeispiel.PNG

 

Auswertungmonat = Month ; it's a built parameter, I have to calculate it.

 

Source data : I have 3 sources, each of them coming from different applications, own logic, norms and reference.


The global program treats first the data of the 1st source, and built the variables for the smallest level of the network (FILBEZ_BT).

Then data from the second source is processed and treated in such a way it can be merged with the 1st. ones.

 

Then the long SQL step I quoted in a preceding post take place and take the raw values to aggregate them and calculate some values of a lot of variables.

 

Afterwards the result table is merged with the 3 one which is delivered with the above structure directly and just needs to be merge each time at the right level.

 

Then all the tables (1 for each level) are added  one after the other to shape the global file.

 

The result of the all is the structure displayed above, WHERE only 2 entities of the smallest level are shown (Example and Group NL Example).

 

i don't know if it is enough to understand.

 

Thanks for helping anyway

 

 

 

ballardw
Super User

It appears that you are looking for different combinations of summaries. That might make proc summary even more attractive.

 

Please examine the output data set from this code:

proc summary data=sashelp.class;
   class sex age;
   var height;
   output out=work.classsummary  mean=;
run;

You will see a variable called _type_ that in this case has values from 0 to 3. The _type_=0 is the summary, mean in this case, across all records in the data set; _type_=1 is the summary only for the levels of Age; _type_ =2 is the summary for levels of Sex ; _type_=3 is the summary for the combined levels of sex and age.

 

If you have a variable that has missing values that you want considered as a separate level then you use the option /missing on a class statement. You can have more than one class statement with different options but ALL of the variables on the class statements will be used to get different summaries.

 

If you only want specific records after a summary step then a data step can select or modify.

You can also summarize many variables and request different statistics. The /autoname option on the OUTPUT statement creates output variables with the statistic appended to the variable name if you don't want to create different variables by hand.

 

If you have actual SAS date values you can use the format applied to a variable to create groups. ( and a WHERE to restrict the range if desired). You should have the SASHELP.STOCKS data set available to see this code. I am creating a custom date format as the SAS supplied YYMM format places an M in the value. Note that the first proc summary step creates a summary of the overall min and max of all of the stock open and close values over the period of time in the data; a summary by calendar month of min and max open and close across all stocks, the min and max of the stock open and close across the time period and the min and max open and close value for each stock and month combination.

The second proc summary does the exact same thing but groups by calendar quarter instead of month. A different format could do the same for calendar years. Custom formats could be made for many types of intervals not supplied by SAS using Proc Format and some ingenuity.

 

proc format library=work;
picture my_ym  (default=6)
low-high='%Y%0m' (datatype=date);
run;

proc summary data=sashelp.stocks;
   class stock date;
   format date  my_ym.;
   var open close;
   output out=work.stocksummary min= max= /autoname;
run;

proc summary data=sashelp.stocks;
   class stock date;
   format date  yyq6.;
   var open close;
   output out=work.stocksummary2 min= max= /autoname;
run;

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
  • 18 replies
  • 1803 views
  • 4 likes
  • 4 in conversation