12-13-2024
unwashedhelimix
Obsidian | Level 7
Member since
10-14-2024
- 18 Posts
- 5 Likes Given
- 0 Solutions
- 2 Likes Received
-
Latest posts by unwashedhelimix
Subject Views Posted 1226 12-11-2024 12:15 AM 758 12-03-2024 02:57 AM 779 12-03-2024 02:25 AM 825 12-02-2024 10:11 PM 1863 12-02-2024 09:22 PM 1945 12-02-2024 05:39 PM 563 11-30-2024 10:58 PM 663 11-25-2024 04:44 AM 700 10-23-2024 12:08 AM 703 10-23-2024 12:06 AM -
Activity Feed for unwashedhelimix
- Posted Imputing the mean for missing the values on SAS Programming. 12-11-2024 12:15 AM
- Posted Re: Counting distinct inputs in a column using proc sql on SAS Programming. 12-03-2024 02:57 AM
- Posted Counting distinct inputs in a column using proc sql on SAS Programming. 12-03-2024 02:25 AM
- Liked Re: PROC TABULATE: Adding .PNG files & colors to an output for Ksharp. 12-03-2024 02:19 AM
- Posted PROC TABULATE: Adding .PNG files & colors to an output on SAS Programming. 12-02-2024 10:11 PM
- Liked Re: Renaming Colums in PROC SQL for Ksharp. 12-02-2024 09:57 PM
- Posted Re: Renaming Colums in PROC SQL on SAS Programming. 12-02-2024 09:22 PM
- Posted Renaming Colums in PROC SQL on SAS Programming. 12-02-2024 05:39 PM
- Posted Issue with the Title Date & Time on SAS Programming. 11-30-2024 10:58 PM
- Posted Issue with Sorting in Chronological Order on SAS Programming. 11-25-2024 04:44 AM
- Got a Like for Re: Where do arrays come in on this task?. 10-23-2024 07:32 AM
- Posted Re: Where do arrays come in on this task? on SAS Programming. 10-23-2024 12:08 AM
- Posted Re: Where do arrays come in on this task? on SAS Programming. 10-23-2024 12:06 AM
- Posted Where do arrays come in on this task? on SAS Programming. 10-22-2024 10:21 PM
- Posted How to Delete Entire Row if Conditions Are Met on SAS Programming. 10-21-2024 03:51 AM
- Posted Re: Getting a PDF Report All on One Page on SAS Programming. 10-21-2024 12:00 AM
- Posted Getting a PDF Report All on One Page on SAS Programming. 10-20-2024 10:51 PM
- Liked Re: Why is the time truncating and how do I fix it? for Ksharp. 10-20-2024 10:36 PM
- Posted Why is the time truncating and how do I fix it? on SAS Programming. 10-20-2024 09:23 PM
- Liked Re: Best Way to Do a Frequency Table for Patient Responses for PaigeMiller. 10-18-2024 01:39 PM
-
Posts I Liked
Subject Likes Author Latest Post 1 2 1 1 1 -
My Liked Posts
Subject Likes Posted 2 10-23-2024 12:08 AM
12-03-2024
06:28 AM
Do not saddle yourself with those stupid name literals. Labels are made for pretty strings, so use them, but keep variable names simple for easier coding.
... View more
12-03-2024
03:14 AM
So using the following code to check if your dataset include this variable: proc contents data=mysas.MyData varnum; run;
... View more
12-03-2024
01:48 AM
1 Like
data cutepets;
length pet $20;
input gender $ pet $ number_of_pets;
cards;
boy cockatiel 1
boy turtle 3
boy rabbit 4
girl cockatiel 2
girl turtle 3
girl rabbit 7
;
run;
proc format;
value $ image(default=80)
'cockatiel'='c:\temp\a.png'
'turtle'='c:\temp\b.png'
'rabbit'='c:\temp\c.png'
;
run;
title "Number of Cute Pets Owned by Families of 3rd Graders";
proc tabulate data=cutepets style=[just=center ];
class gender /style={background=blue color=white};
class pet /style={background=pink color=white};
classlev gender /style={background=purple color=white};
classlev pet /style={background=green color=white postimage=$image80. };
var number_of_pets;
table gender='Gender',
pet='Pet'* number_of_pets='' * sum=' ' /
box='# of Pets' misstext='0';
run;
... View more
12-01-2024
01:02 AM
%let current_datetime = %sysfunc(datetime(), mdyampm.);
title1 "First Name & Last Name";
title2 "Date and Time: ¤t_datetime";
proc print data=sashelp.class;
run;
... View more
11-25-2024
09:17 PM
1 Like
Your PROC FORMAT is NOT right.
data docvisits;
input patientID $ weekday :$20. score;
cards;
101 Friday 15
163 Wednesday 11
104 Friday 23
163 Thursday 13
123 Tuesday 10
104 Monday 20
157 Friday 21
101 Monday 10
112 Tuesday 11
157 Tuesday 10
123 Monday 9
123 Friday 9
101 Tuesday 11
112 Monday 9
157 Thursday 18
174 Monday 12
;
proc format;
invalue weekdayfmt
'Monday' = 1
'Tuesday' = 2
'Wednesday' = 3
'Thursday' = 4
'Friday' = 5;
run;
data docvisits_sorted;
set docvisits;
daynum = input(weekday, weekdayfmt.);
run;
proc sql nowarn;
select distinct weekday, count(distinct patientID) as Total_Patients
from docvisits_sorted
group by weekday
order by daynum;
quit;
... View more
10-23-2024
12:08 AM
2 Likes
Ohp, I got it. Disregard!
... View more
10-21-2024
08:10 AM
Another approach using ABS function. If we need to read only observations where change is greater than or equals 10 then where statement is more efficient in terms of system processing.
data want;
set have;
where abs(starting_weight - end_weight) ge 10;
run;
... View more
10-21-2024
02:00 AM
I wrote a PROC FREQ is just to make a sample data since you did not post a data. You can delete PROC FREQ and use your original dataset to PROC PRINT. " but the report wasn't quite in a format like " What do you mean by that ? you can format your report as your wish/code : options nodate nonumber papersize=(21cm 38cm) ; ods pdf file = "c:\temp\temp.pdf" style=journal ; proc print data = StateDataSet NOOBS label ; format Area Comma7.0 Population Comma10.0; title ; label State_Name = 'State Name'; label State_Abbrev = 'State Abbrev.'; label Postal_Abbrev = 'Postal Abbrev.'; label Area = 'Area (Sq Mi)'; run; ods pdf close;
... View more
10-21-2024
12:09 AM
Count the columns.
You can use the LIST statement to have SAS print it out for you to the SAS log.
RULE: ----+----1----+----2----+----3----+----4----+----5-
1 2022/01/10 14:54:28.81 0.36 33.512 -116.768 43
2 2022/01/10 15:16:32.60 0.96 33.184 -116.031 43
3 2022/01/10 15:43:09.41 1.09 35.680 -117.535 43
4 2022/01/10 16:33:07.48 0.68 33.588 -116.808 43
5 2022/01/10 17:14:17.90 0.86 36.032 -117.807 43
6 2022/01/10 18:00:07.32 0.61 35.765 -117.580 43
7 2022/01/10 18:50:47.06 0.90 35.586 -117.462 43
8 2022/01/10 18:59:47.00 2.61 35.648 -115.927 43
NOTE: 8 records were read from the infile HAVE.
The minimum record length was 43.
The maximum record length was 43.
You asked the INPUT statement to read the first two variables using FORMATTED MODE and the other three variables using LIST MODE. So it read DATE from columns 1 to 10. Then TIME from columns 11 to 21 leaving the pointer at column 22. So for MAGNITUDE it read the last digit of the TIME value. And you never read in the last value on the line.
So either adjust the width of the TIME informat to account for the leading and trailing space.
input Date yymmdd10. Time time13. Magnitude Latitude Longitude;
Or if the values are not in fixed column locations, but every field has a value on every line (with single periods used to mark the missing values) then just use LIST MODE for all of the fields instead of just the last three. You could use an INFORMAT statement to attach the desired informats to DATE and TIME.
data have;
infile have truncover;
input Date Time Magnitude Latitude Longitude;
informat date yymmdd. time time.;
format date yymmdd10. time timeampm14.2;
run;
Or instead if you want to specify the informat in-line in the INPUT statement then make sure to use the colon modifier so that the INPUT statement still uses LIST MODE instead of switching to FORMATTED MODE for those variables.
input Date :yymmdd. Time :time. Magnitude Latitude Longitude;
Remember that in LIST MODE input the width attached to the informat specification is ignored. Instead the whole next field on the line is read, however many bytes it takes. So no need to specify any width at all.
To display 8 character time values with a decimal point and two places to the right of the decimal point and a space and two letter suffix will requried using the format specification timeampm14.2.
... View more
10-18-2024
04:13 PM
data pizza_likes; input ID $ A $ B $; datalines; 21 Yes No 22 No No 23 Yes Yes 24 No Yes 25 Yes Yes 26 Yes No 27 No Yes ; run;
proc freq data=pizza_likes; tables A*B / nocol nopercent norow; run;
proc sql; select sum(A='Yes') as Likes_A, sum(B='Yes') as Likes_B, sum(A='Yes' and B='No') as Likes_Only_A, sum(A='No' and B='Yes') as Likes_Only_B, sum(A='Yes' and B='Yes') as Likes_Both, sum(A='No' and B='No') as Likes_Neither, sum(A='Yes' or B='Yes') as Likes_Either from pizza_likes; quit;
... View more
10-14-2024
10:49 PM
@unwashedhelimix wrote:
Thanks for the reply! I just saw it after revising my question a bit. I appreciate the guidance on the conversion, but I thought it would be a better report if the missing cells (not the entire row) were deleted.
I do not know what you mean by that comment. There is no need to delete observations (or values). Can you explain what you meant more clearly?
If you have data as you posted (with numeric variables) SAS will handle it properly.
data have;
input Age Points Assists Rebounds Steals;
cards;
21 12.1 7.2 7.4 1.2
26 20.3 7.2 . 1.2
21 10 . 7.4 .
19 8.4 10.1 . 2.3
;
For example the mean values will be calculated using only the non-missing values.
The MEANS Procedure
Variable N Mean Std Dev Minimum Maximum
-----------------------------------------------------------------------------
Age 4 21.7500000 2.9860788 19.0000000 26.0000000
Points 4 12.7000000 5.2883520 8.4000000 20.3000000
Assists 3 8.1666667 1.6743158 7.2000000 10.1000000
Rebounds 2 7.4000000 0 7.4000000 7.4000000
Steals 3 1.5666667 0.6350853 1.2000000 2.3000000
-----------------------------------------------------------------------------
... View more