11-13-2024
ciro
Quartz | Level 8
Member since
07-05-2011
- 112 Posts
- 31 Likes Given
- 0 Solutions
- 2 Likes Received
-
Latest posts by ciro
Subject Views Posted 1241 05-30-2024 11:18 AM 1260 05-30-2024 10:35 AM 1267 05-30-2024 10:33 AM 1371 05-30-2024 07:30 AM 3894 07-26-2023 04:56 AM 3974 07-25-2023 09:55 AM 4037 07-25-2023 08:15 AM 4023 07-25-2023 08:14 AM 4050 07-25-2023 08:09 AM 4078 07-25-2023 07:37 AM -
Activity Feed for ciro
- Posted Re: deduplicate data constrained to have different values across subgroups on SAS Programming. 05-30-2024 11:18 AM
- Posted Re: deduplicate data constrained to have different values across subgroups on SAS Programming. 05-30-2024 10:35 AM
- Posted Re: deduplicate data constrained to have different values across subgroups on SAS Programming. 05-30-2024 10:33 AM
- Posted deduplicate data constrained to have different values across subgroups on SAS Programming. 05-30-2024 07:30 AM
- Posted Re: minimize sum of distances given contraints on Mathematical Optimization, Discrete-Event Simulation, and OR. 07-26-2023 04:56 AM
- Liked Re: minimize sum of distances given contraints for RobPratt. 07-26-2023 04:44 AM
- Liked Re: minimize sum of distances given contraints for Rick_SAS. 07-26-2023 04:44 AM
- Posted Re: minimize sum of distances given contraints on Mathematical Optimization, Discrete-Event Simulation, and OR. 07-25-2023 09:55 AM
- Posted Re: minimize sum of distances given constraints on Mathematical Optimization, Discrete-Event Simulation, and OR. 07-25-2023 08:15 AM
- Posted minimize sum of distances given contraints on Mathematical Optimization, Discrete-Event Simulation, and OR. 07-25-2023 08:14 AM
- Posted Re: minimize sum of distances given constraints on Mathematical Optimization, Discrete-Event Simulation, and OR. 07-25-2023 08:09 AM
- Posted minimize sum of distances given constraints on Mathematical Optimization, Discrete-Event Simulation, and OR. 07-25-2023 07:37 AM
- Posted Re: nested list to represent data structure on ODS and Base Reporting. 03-29-2023 04:22 AM
- Liked Re: nested list to represent data structure for Ksharp. 03-28-2023 11:11 AM
- Posted Re: nested list to represent data structure on ODS and Base Reporting. 03-28-2023 08:36 AM
- Posted nested list to represent data structure on ODS and Base Reporting. 03-28-2023 06:46 AM
- Posted Re: distances between observations within groups on Statistical Procedures. 01-30-2023 11:48 AM
- Liked Re: distances between observations within groups for sbxkoenk. 01-30-2023 11:26 AM
- Posted Re: distances between observations within groups on Statistical Procedures. 01-27-2023 07:21 AM
- Posted distances between observations within groups on Statistical Procedures. 01-26-2023 05:12 AM
-
Posts I Liked
Subject Likes Author Latest Post 2 1 2 1 1 -
My Liked Posts
Subject Likes Posted 2 10-26-2017 12:50 PM
05-30-2024
11:18 AM
Dear Ballardw,
thank you very much for your kind and insigthful replay.
Maybe I should have posted the problem at an earlier stage as you suggested.
let me try again.
the dataset have is the result of this operation:
data have1; input group $ match x; cards; a 1000 1 a 1000 2 a 1000 3 b 2000 1 b 2000 2 b 2000 3 b 2000 4 ; run;
data have2; input group $ match id; cards; a 1000 2 a 1000 3 a 1000 4 b 2000 2 b 2000 3 b 2000 4 b 2000 5 ; run;
proc sql; create table have as select a.*,b.id from have1 as a left join have2 as b on a.group=b.group and a.match=b.match order by group, id, x; quit;
data have; retain group id x; set have; run;
In other terms I have to match the subject x of have1 within group with the id of have2.
the two dataset have only in common the variable group and the variable match. the problem is that
within a group different subjects can have the same match variable but in the want dataset I need that x in each group be unique.
You are right the real problem is more complex as there can be exceeding rows in both datasete and/or the matching variable do not match. In reality what I would like is to have those that have not joined in residuals dataset.
The problem presented is a simplification to start to solve the problem of having multiple subject with the same matching variable and an equal number of subjects.
Thank you again in advance.
... View more
05-30-2024
10:35 AM
data have; input group $ id x; cards; a 2 1 a 2 2 a 2 3 a 3 1 a 3 2 a 3 3 a 4 1 a 4 2 a 4 3 b 2 1 b 2 2 b 2 3 b 2 4 b 3 1 b 3 2 b 3 3 b 3 4 b 4 1 b 4 2 b 4 3 b 4 4 b 5 1 b 5 2 b 5 3 b 5 4 ; run;
... View more
05-30-2024
10:33 AM
What it is needed is just that within group x is unique, even if it is choosen ar random within id
... View more
05-30-2024
07:30 AM
Hi,
I would like to deduplicate the dataset 'have' with the constraint that for each 'group' there will be an observation for each 'id' and that across ids within 'group' all the 'x' values are different.
My dataset want should be like this:
group
id
x
a
2
1
a
3
2
a
4
3
b
2
1
b
3
3
b
4
4
b
5
2
I would appreciate very much a range of techniques.
thank you very much in advance
... View more
07-26-2023
04:56 AM
@RobPratt
Thank you very much Rob!
I have a question, maybe just trivial. the objective function seems to be defined over all groups and not within each group. Isn't the solution different from the within group minimization?
Unfortunately I don'have Sas Viya and cannot perform "by group processing".
Another question. my real data is much bigger: a larger number of groups (say about 10k), a huge number of subjects within (some of the groups- up to 1m) and, say, about 8k areas in few groups.
do you foresee problems with the resources and have any suggestion to optimize the code?
... View more
07-25-2023
09:55 AM
Thank you Rick for your message.
the reason why the freq does not return the same number of records for each area is that each group has different areas, or in other terms the fact the two groups has some areas in common is just a coincidence.
rerunning the freq as follows all areas has the same number of observations, within each group.
proc freq data=prova.have; tables group*area /list missing; run;
The problem I posted is a minimization problem within group
I will try to follow you suggestion, but since I am short of time I would appreciate very much any code.
... View more
07-25-2023
08:15 AM
Reposted in SAS/OR forum
... View more
07-25-2023
08:14 AM
Hi,
in the dataset have, for each group, there is the distance between each subject and many areas.
in the dataset have_contraints, for each group, there is the number of subjects that belongs to each area.
I would like to assign each subject to only one area minimizing the sum of distances within each group given the constraint that the number of subjects in each area within the group is that of table
have_contraints.
I would appreciate any solution with proc optmodel and/or with IML. As I am not proficient in any of them I would also appreciate very much a description of the code.
thank you very much in advance
@RobPratt
@Rick_SAS
... View more
07-25-2023
08:09 AM
I apologize, I posted in the wrong forum. can I readdress it or have to post it again?
... View more
07-25-2023
07:37 AM
Hi,
in the dataset have, for each group, there is the distance between each subject and many areas.
in the dataset have_contraints, for each group, there is the number of subjects that belongs to each area.
I would like to assign each subject to only one area minimizing the sum of distances within each group given the constraint that the number of subjects in each area within the group is that of table
have_contraints.
I would appreciate any solution with proc optmodel and/or with IML. As I am not proficient in any of them I would also appreciate very much a description of the code.
thank you very much in advance
... View more
03-29-2023
04:22 AM
Thank you Ksharp. Very interesting solution. I learnt a new possibility.
I'd like to wait a little more for an odslist solution.
... View more
03-28-2023
08:36 AM
dear Paige,
thank you for your answer.
I had read that example and others, but my problem is a bit different, I think as the sublists and level of
indentation have to be initiated according to some conditions.
... View more
03-28-2023
06:46 AM
hello,
in my work I often would like to report the data structure as a tree with nodes and subnodes.
I recently discovered odslist that seems to have the capacity to present information as a nested list.
for instance I can represent my data in a parent child structure as follows:
id
parent
n
G
100
G1
G
60
G11
G1
40
G12
G1
20
G2
G
10
G21
G2
10
G3
G
30
G31
G3
10
G32
G3
5
G33
G3
15
and I would like to represent tham in the following way:
G 100 records
G1 60 records
G11 40 records
G12 20 records
G2 10 records
G21 10 records
G3 30 records
G31 10 records
G32 5 records
G33 15 records
Is it possible with odslist? any suggestion and especially code is very appreciated.
thanks in advance
... View more
01-30-2023
11:48 AM
Thank You Koen,
I marked my second message as solution by mistake, since I wanted to mark yours as solution. apologies.
I don't know how to undo the marking. I wrote to sas to ask the unmarking.
Let's see if they respond.
... View more
01-27-2023
07:21 AM
thank you very much.
the only thing missing is that I need to know which is mached to any id, but I can obtain that
with a little coding like this.
is it correct?
proc sort data=sashelp.class out=class; by sex name; run;
proc distance data=class out=dist method=euclid SHAPE=SQUARE; by sex; copy name; var interval(age height weight); run;
data dist; set dist; by sex; retain id2; if first.sex then id2=1; else id2+1; run;
data dist_trp(drop=dist1-dist10); *data dist_trp; set dist; by sex; array dist{10} dist1-dist10; do Person_withinSameSex = 1 to dim(dist); distance_euclid=dist(Person_withinSameSex); output; end; run;
proc sql; create table dist_trp as select a.*,b.name as name_matched from dist_trp as a left join dist as b on a.sex=b.sex and a.Person_withinSameSex=b.id2 order by sex,id2,Person_withinSameSex; quit;
... View more