06-08-2023
PavelD
Obsidian | Level 7
Member since
06-13-2018
- 33 Posts
- 70 Likes Given
- 1 Solutions
- 11 Likes Received
-
Latest posts by PavelD
Subject Views Posted 587 03-15-2023 06:10 AM 618 03-15-2023 04:48 AM 798 02-05-2023 03:42 AM 881 02-03-2023 06:26 AM 2527 02-17-2022 02:11 PM 1101 02-17-2022 01:53 PM 2561 02-17-2022 09:43 AM 2561 02-17-2022 09:39 AM 2586 02-17-2022 07:46 AM 1170 02-17-2022 07:24 AM -
Activity Feed for PavelD
- Posted Re: PROC summary with preloadfmt option truncates char variables on SAS Programming. 03-15-2023 06:10 AM
- Liked Re: PROC summary with preloadfmt option truncates char variables for Kurt_Bremser. 03-15-2023 06:09 AM
- Posted PROC summary with preloadfmt option truncates char variables on SAS Programming. 03-15-2023 04:48 AM
- Liked Re: How to get all the list of all files as a dataset from particular folder? for AMSAS. 02-10-2023 03:25 AM
- Liked Re: Disable message "Open files have been modified by external editor" for SASKiwi. 02-06-2023 02:47 AM
- Posted Re: Disable message "Open files have been modified by external editor" on SAS Enterprise Guide. 02-05-2023 03:42 AM
- Posted Disable message "Open files have been modified by external editor" on SAS Enterprise Guide. 02-03-2023 06:26 AM
- Liked Re: Calculate percentages and counts with PROC SQL for PaigeMiller. 02-25-2022 06:42 AM
- Liked Re: Average by Excluding One Observation at a Time for PGStats. 02-18-2022 10:58 AM
- Liked Re: Hardcoding format after PROC SUMMARY for PaigeMiller. 02-18-2022 10:53 AM
- Got a Like for Re: Hardcoding format after PROC SUMMARY. 02-18-2022 08:26 AM
- Posted Re: Hardcoding format after PROC SUMMARY on SAS Programming. 02-17-2022 02:11 PM
- Posted Re: Hardcoding format after PROC SUMMARY on SAS Programming. 02-17-2022 01:53 PM
- Liked Re: Hardcoding format after PROC SUMMARY for Astounding. 02-17-2022 01:51 PM
- Posted Re: Hardcoding format after PROC SUMMARY on SAS Programming. 02-17-2022 09:43 AM
- Liked Re: Hardcoding format after PROC SUMMARY for PaigeMiller. 02-17-2022 09:40 AM
- Posted Re: Hardcoding format after PROC SUMMARY on SAS Programming. 02-17-2022 09:39 AM
- Liked Re: Hardcoding format after PROC SUMMARY for acordes. 02-17-2022 09:39 AM
- Liked Re: Hardcoding format after PROC SUMMARY for data_null__. 02-17-2022 09:36 AM
- Liked Re: Hardcoding format after PROC SUMMARY for JosvanderVelden. 02-17-2022 08:10 AM
-
Posts I Liked
Subject Likes Author Latest Post 1 4 1 3 5 -
My Liked Posts
Subject Likes Posted 2 02-17-2022 09:39 AM 2 07-09-2018 04:17 PM 4 07-06-2018 02:26 PM 3 06-28-2018 02:28 AM
03-15-2023
06:10 AM
Fantastic, thanks Kurt. I missed that option.
... View more
03-15-2023
04:48 AM
hello code: data data_in;
length Name $10;
/* without the line above, Name has length 8 */
set sashelp.class;
/* Name has length 10 - as expected */
run;
proc format ;
value $Name (multilabel)
"Alfred" = "Alfred"
"Alice" = "Alice"
"Alice" = "Aggr"
"Alfred" = "Aggr"
other = "other"
;
run;
proc summary nway data = data_in completetypes;
class Name / preloadfmt mlf;
var Weight;
format Name $Name.;
output out = data_out ( DROP = _TYPE_ _FREQ_) sum = ;
/* in data_out, Name has length 6, and NOT 10 ! */
run; in data_in, Name has length 10. In data_out, Name has length 6. Is there a way to force proc summary to MAINTAIN the length of the class variable? thx
... View more
02-05-2023
03:42 AM
Thanks kiwi 🥝 I think the best bet would be to use autohotkey and automatically confirm and close the window that appears. Thank you for your help!
... View more
02-03-2023
06:26 AM
hello my problem seems unrelated to this issue: https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Guide-8-2-Windows-quot-Open-file-have-been-modified-by-an/m-p/670595#M36472 I do frequently edit an OPEN program in SAS EG both in SAS EG and via an external editor. Each time this happens, the following message appears in SAS EG: is there any way to disable this message and always automatically accept the modifications, even after opening SAS EG next time? SAS EG version: 8.3 Update 3 (8.3.3.181) (64-bit) thanks!!
... View more
02-17-2022
02:11 PM
Both @data_null__ and @PaigeMiller have hundreds of replies on your account, since neither of you understood what I wanted to say, I think we all agree the problem is not on your side, but on mine. You are right, starting a new thread would be a better idea at this point! Thanks!
... View more
02-17-2022
01:53 PM
Hello, yes I see what you mean. I also thought about this at the beginning, the issue is that I have around 14 or 15 classes. So removing nway would lead to a lot of editing afterwards I thought. I find data null's answer that helps hard code the format within proc summary the best suited for my problem. Thanks @Astounding!
... View more
02-17-2022
09:43 AM
Thanks @PaigeMiller, I am sorry I cannot provide more details, nor the desired result, I think it would be a lots of tables and I dont think it would bring much value. Thanks for your help!!
... View more
02-17-2022
07:46 AM
In addition, let's move away from the actual code for a second and explain the analysis you are trying to do from a higher level, with no discussion of code. You have data, you want a certain result, what is that desired result (without mentioning code)? Show us the desired result. Good point, I should have started with this in the first place. I appreciate your patience, @PaigeMiller and @Kurt_Bremser and others. Maybe my choice of procs will turn out to be wrong completely. So, I have raw data, let's say 10 columns, of which one is numeric (the VAR in proc summary). Of this raw data I need to create dozens of partially aggregated datasets, using predefined set of custom formats which I apply to 2-4 columns each time. I need to maintain the structure of the raw dataset, i.e. the 9+1 columns, so I put all 9 in the CLASS. My other idea was that I could have did some remerging after proc summary but I did not like that option, I always try to look for the simplest option. So now I have dozens of aggregated datasets, since they all have the same structure, I wanted to SET them together and create a single dataset, but that failed completely because each dimension adopted the zombie format from the first SET dataset, and as I wrote above the formats differed in each aggregation. Ultimately I wanted to export it into CSV, so I simply exported dozens of CSVs instead of one. This worked. What I meant was that in my situation, it would simply be easier to hardcode formats after each aggregation, perhaps with VVALUE as another member suggested, I thought about that, but I was just hoping there is a neater, cleaner option. If you have any idea or general remarks, I am all ears. Thanks!!
... View more
02-17-2022
07:24 AM
Thanks Kurt, but in fact the format is maintained in have2 (i.e. the "T" is still not raw):
... View more
02-17-2022
07:14 AM
Hello @PaigeMiller, thanks for your answer. I find it hard to believe that when aggregating over values, proc summary takes the first value as a label. I cannot think of a situation where that can be useful and not misleading... From your comment I understand that is the expected behaviour? When you look at the last dataset, you see that the total for category "A" is 15. That is wrong. I would not care as much and simply keep using the formatted value, except that in some procedures or functions SAS takes the formatted values, sometimes the unformatted value. What I want is really to force the proc summary to use the format only once in the aggregation, not to assign it permanently to the variable while keeping the unformatted values. Something like the put function in a data step: new_var = put(other_var, $my_format.); In this case new_var is not assigned permanently $my_format. Maybe my whole approach is not SAS-y enough, maybe there is a better way. I just cant think of any simple way...
... View more
02-17-2022
05:27 AM
Hello! imagine a dataset and format like this: data have;
input my_category $ value;
datalines;
A 1
A 0
A 3
B 7
B 3
B 1
;
run;
proc format ;
value $total_format
other = "T"
;
run; I want to aggregate over my_category, using a custom format (i know, in this simple example I could simply remove my_category from CLASS, but I need to have the column my_category = T in the output dataset). So I use proc summary: proc summary nway data = have;
class my_category;
var value;
format my_category $total_format.;
output out = have_summed sum = ;
run; this produces: my_category _TYPE_ _FREQ_ value
T 1 6 15 This is expected, so far so good. However, my_category retains the format $total_format, instead of... hardcoding it. That means that if you remove the format with the following: data have2;
set have_summed;
format my_category;
run; the result is: my_category _TYPE_ _FREQ_ value
A 1 6 15 i.e. "A" instead of "T", which is simply wrong! In have_summed, the column my_category appears to have the value "T". If you export have_summed to a CSV, the formatted value "T" is retained. But if you use for example the CATS/CATX function with my_category, it does not use "T" but "A", i.e. the unformatted value. I find this very confusing. What am I missing? Is there a better way? Platform SAS 9.4.7.0.
... View more
- Tags:
- format
- proc summary
12-10-2018
11:54 AM
Thank you @Reeza, I see your point (sorry for not replying to you directly, I wrote it on the phone and there is no "reply to" option).
... View more
12-10-2018
10:25 AM
Hi PaigeMiller, sorry I have given maybe a wrong example. It is a coincidence that entity is nicely sorted in the "want" dataset. Let me edit.
... View more
12-10-2018
10:22 AM
hi! I am struggling with a seemingly simple problem. Have: see below Want: grouped by entity, these groups then sorted by per. So the highest per at the top. Per is missing when period=2. I consulted "Custom Sorting with the Case Statement" but didn't manage to connect the dots. Any ideas? Thank you have entity period per
A 1 5
B 1 9
C 1 7
A 2 .
C 2 .
B 2 .
want entity period per << grouped by entity, sorted by per
B 1 9
B 2 .
C 1 7
C 2 .
A 1 5
A 2 . edit 2018-12-10 16:26: clarification (entity order in "want" is not important, but they need to be grouped) edit 2018-12-11 08:13: following @Reeza's suggestion, below is my tentative (but working) implementation: edit 2018-12-11 14:13: you may shorten the code by using the SAS rank procedure instead of data step / proc sort combination. data have;
input entity $ period per;
datalines;
A 1 5
B 1 9
C 1 7
A 2 .
C 2 .
B 2 .
;
run;
/* sorted have dataset
entity period per
B 1 9
C 1 7
A 1 5
A 2 .
C 2 .
B 2 .
*/
proc sort data = have; by descending per period; run;
/* have1 = have with a custom order added (period=1 only)
entity period per custom_order
B 1 9 1
C 1 7 2
A 1 5 3
A 2 . .
C 2 . .
B 2 . .
*/
data have1;
set have;
if period = 1 then custom_order + 1 ;
else custom_order = .;
run;
/* have1, sorted
entity period per custom_order
A 1 5 3
A 2 . .
B 1 9 1
B 2 . .
C 1 7 2
C 2 . .
*/
proc sort data = have1; by entity period; run;
/* want, unsorted yet
entity period per dummy
A 1 5 3
A 2 . 3
B 1 9 1
B 2 . 1
C 1 7 2
C 2 . 2
*/
data want (drop = custom_order);
set have1;
retain dummy 0;
by entity period;
if first.entity then dummy = custom_order;
run;
/* final, sorted want:
entity period per dummy
B 1 9 1
B 2 . 1
C 1 7 2
C 2 . 2
A 1 5 3
A 2 . 3
*/
proc sort data = want; by dummy period ; run;
... View more