yesterday
PeterClemmensen
Tourmaline | Level 20
Member since
01-27-2015
- 5,868 Posts
- 2,297 Likes Given
- 1,072 Solutions
- 2,198 Likes Received
This widget could not be displayed.
-
Latest posts by PeterClemmensen
Subject Views Posted 478 a week ago 181 2 weeks ago 228 2 weeks ago 2354 02-19-2025 07:46 AM 380 02-16-2025 01:14 PM 453 01-16-2025 04:02 AM 480 01-15-2025 01:55 PM 502 01-15-2025 01:35 PM 1182 01-07-2025 06:33 AM 1928 01-07-2025 06:07 AM -
Activity Feed for PeterClemmensen
- Liked Re: Mutliple conditions applying on multiple values based on row wise for Tom. yesterday
- Posted Re: How do i take the date value of the next row record and deduct by 1 day? on SAS Programming. a week ago
- Liked Re: Merging 2 data sets and assigning the same record_id based on common var for Ksharp. 2 weeks ago
- Got a Like for Re: format date with underscore. 2 weeks ago
- Got a Like for Re: flagging duplicate rows with complex request. 2 weeks ago
- Got a Like for Re: flagging duplicate rows with complex request. 2 weeks ago
- Posted Re: flagging duplicate rows with complex request on SAS Programming. 2 weeks ago
- Posted Re: format date with underscore on SAS Programming. 2 weeks ago
- Got a Like for Re: datetime format for dd.mm.yyyy hh:mm?. a month ago
- Got a Like for Re: number missing values in each obs (Numeric). 02-19-2025 10:19 AM
- Got a Like for Re: number missing values in each obs (Numeric). 02-19-2025 09:42 AM
- Got a Like for Re: number missing values in each obs (Numeric). 02-19-2025 07:56 AM
- Posted Re: number missing values in each obs (Numeric) on SAS Programming. 02-19-2025 07:46 AM
- Liked Re: Index function with % and single quote for FreelanceReinh. 02-18-2025 06:12 AM
- Liked Re: SET data set-Run speed for Patrick. 02-18-2025 03:12 AM
- Posted Re: Please check why step two has an error message...Thanks! on SAS Programming. 02-16-2025 01:14 PM
- Liked Re: percent8.2 format for Amir. 01-30-2025 02:41 AM
- Liked Re: By Group how to Identify if one of the Visit is Present however another Visit is missing. for Patrick. 01-29-2025 03:25 AM
- Liked Re: DOSUBL inside PROC SQL? for ChrisNZ. 01-28-2025 03:47 AM
- Liked Re: How do i aggregate and count a variable where X < 2 correctly? for rudfaden. 01-21-2025 03:24 AM
-
-
My Liked Posts
Subject Likes Posted 1 2 weeks ago 2 2 weeks ago 3 02-19-2025 07:46 AM 1 11-26-2019 10:13 AM 1 01-07-2025 06:07 AM
a week ago
"It is possible to have more than 10 rows of such a record with unique "END_NUM" value for the same POLICE_ID and POLICE_YEAR."
I don't understand this. Please provide sample data that resembles your request.
Why is POLICE_EXP = 14-APR-24 in the second obs ?
... View more
2 weeks ago
2 Likes
How about
data have;
input SEQUENCE_NO_ (VISIT_DATE scan_date)(:mmddyy10.) location :$1.;
format VISIT_DATE scan_date mmddyy10.;
datalines;
2 1/16/2018 1/16/2018 a
2 4/12/2018 4/12/2018 a
2 8/23/2018 8/23/2018 a
2 2/26/2019 2/26/2019 a
2 9/5/2019 2/26/2019 a
2 3/2/2020 2/26/2019 a
2 9/5/2019 9/3/2019 a
2 3/2/2020 9/3/2019 a
2 3/2/2020 2/27/2020 a
3 7/2/2020 6/16/2020 c
3 10/1/2020 6/16/2020 c
3 4/1/2021 6/16/2020 c
3 9/27/2021 6/16/2020 c
3 7/2/2020 6/16/2020 e
3 10/1/2020 6/16/2020 e
3 4/1/2021 6/16/2020 e
3 9/27/2021 6/16/2020 e
3 7/2/2020 6/16/2020 d
3 10/1/2020 6/16/2020 d
3 4/1/2021 6/16/2020 d
3 9/27/2021 6/16/2020 d
3 3/28/2022 3/24/2022 c
3 3/28/2022 3/24/2022 e
3 3/28/2022 3/24/2022 d
3 9/29/2022 9/27/2022 c
3 9/29/2022 9/27/2022 e
;
data want;
set have;
by SEQUENCE_NO_ location notsorted scan_date notsorted;
if not first.scan_date then flag = 'duplicate';
run;
... View more
2 weeks ago
1 Like
It doesn't exist out-the-box, but you can roll out your own using Proc Format
proc format;
picture dtfmt other = '%m_%D_%Y' (datatype=date);
run;
%let runDate=%sysfunc(putn(%sysfunc(date()), dtfmt.));
%put &=runDate.;
... View more
02-19-2025
07:46 AM
3 Likes
Because nr_Numeric_Missing_Values itself is initialized as a numeric variable. Therefore, it is captured by the _NUMERIC_ list. The calculation of the number of missing values in the NMISS Function occurs before the value is assigned to the variable. Therefore, you get a result +1 of what you expect in each observation.
This gives you the result you want
data my_data;
input team $ points assists rebounds;
cards;
A 10 2 .
A 17 5 .
A 17 . .
A 18 3 4
A 15 0 5
B . 4 5
B 29 0 8
B . 2 9
C 12 1 9
. 30 1 .
;
run;
data want;
set my_data;
nr_Numeric_Missing_Values = nmiss(points, assists, rebounds);
Run;
... View more
02-16-2025
01:14 PM
What is the error message? What does &statelist contain?
... View more
01-16-2025
04:02 AM
Since your data is already sorted the wayt you want it, you can do this
data want;
set mad_age;
by POL_ID POL_CLS POL_YEAR MAD_AGE;
if first.POL_ID then youngest_player = mad_age;
retain youngest_player;
run;
Result:
POL_ID POL_CLS POL_YEAR MAD_AGE flag youngest_player
AAA BLUE 2024 21 Y 21
AAA BLUE 2024 26 21
AAA BLUE 2024 56 21
BBB GREY 2025 18 Y 18
... View more
01-15-2025
01:55 PM
Try this
data have;
input customer_id basket $ 3-35;
datalines;
1 Product1 / Product2 / Product3
2 Product1
3 Product1 / Product2
;
data temp(keep = customer_id w d);
set have;
do c = 1 to countw(basket);
w = scan(basket, c, ' /');
d = 1;
output;
end;
run;
proc transpose data = temp out = want(drop = _:);
by customer_id;
id w;
var d;
run;
... View more
01-15-2025
01:35 PM
Can basket contain other strings than Product1, Product2 and Product3?
... View more
01-07-2025
06:33 AM
Try this
data want;
set have;
by CustID;
if first.CustID then serial = 1;
if Ind then serial + 1;
run;
... View more
01-07-2025
06:07 AM
1 Like
I edited the DB1 data a bit. I assume you want Visit_date to have the date9 format (not Visit).
Here is how I interpret your logic: For each observation in DB you want to evaluate each Visit_date in DB1 . If Visit_date is within the range of Range1 and Range2 for any observation in DB1, set Visit = 1. If not, set Visit = 0.
data DB;
input ID :$20. Admission :date09. Discharge :date09. Range1 :date09. Range2 :date09.;
format Admission date9. Discharge date9. Range1 date9. Range2 date9.;
cards;
0001 13JAN2017 25JAN2017 30DEC2016 24FEB2017
0001 22FEB2017 07MAR2017 08FEB2017 06APR2017
0001 27APR2017 16MAY2017 13APR2017 15JUN2017
0001 30JAN2019 04MAR2019 16JAN2019 03APR2019
0002 28DEC2014 03JAN2015 14DEC2014 02FEB2015
0002 03MAR2015 12MAR2015 20FEB2015 02APR2015
;
data DB1;
input ID :$20. Visit_date :date09.;
format Visit_date date09.;
cards;
0001 26JAN2017
0001 10FEB2017
0002 22FEB2015
;
data DB2(drop = Visit_date);
if _N_ = 1 then do;
dcl hash h(dataset : 'DB1', multidata : 'Y');
h.definekey('ID');
h.definedata('Visit_date');
h.definedone();
end;
set DB;
Visit_date = .;
Visit = 0;
do while (h.do_over() = 0);
if Range1 <= Visit_date <= Range2 then Visit = 1;
end;
run;
Result:
ID Admission Discharge Range1 Range2 Visit
0001 13JAN2017 25JAN2017 30DEC2016 24FEB2017 1
0001 22FEB2017 07MAR2017 08FEB2017 06APR2017 1
0001 27APR2017 16MAY2017 13APR2017 15JUN2017 0
0001 30JAN2019 04MAR2019 16JAN2019 03APR2019 0
0002 28DEC2014 03JAN2015 14DEC2014 02FEB2015 0
0002 03MAR2015 12MAR2015 20FEB2015 02APR2015 1
... View more
01-07-2025
04:19 AM
1 Like
Here is an easy to follow approach
data want;
set sorted_string;
array a {100} $ _temporary_;
N = 5;
pos = max(1, length(str)-(N - 1));
sub = substrn(str, pos, N);
do i = 1 to length(sub);
a[i] = char(sub, i);
end;
call sortc(of a[*]);
substr(str, max(1, pos, N)) = cats(of a[*]);
run;
... View more
12-18-2024
03:21 AM
1 Like
Try using
options missing="";
before the Proc Print
... View more
12-18-2024
03:16 AM
How do you export to Excel?
... View more