
11-30-2023
Tpham
Quartz | Level 8
Member since
04-09-2013
- 84 Posts
- 6 Likes Given
- 1 Solutions
- 2 Likes Received
About
HIV/AIDS, Health Disparities, Health Services Research, Clinical Research, Patient Centered Outcomes, Measurement Theory
-
Latest posts by Tpham
Subject Views Posted 1161 04-19-2023 06:39 PM 4476 11-24-2022 09:18 PM 4538 11-24-2022 10:37 AM 4538 11-24-2022 10:36 AM 4540 11-24-2022 10:33 AM 4623 11-24-2022 12:27 AM 1450 11-08-2021 08:17 PM 1476 11-08-2021 08:10 PM 1488 11-08-2021 07:11 PM 5812 08-11-2021 09:08 AM -
Activity Feed for Tpham
- Posted Proc report, how to apply same compute condition on multiple variables? on SAS Programming. 04-19-2023 06:39 PM
- Got a Like for Proc Report, Merging cells when grouped and vertical center. 01-22-2023 07:18 PM
- Posted Re: How to randomize Subjects into 2 groups and balance based on demographics? on SAS Programming. 11-24-2022 09:18 PM
- Posted Re: How to randomize Subjects into 2 groups and balance based on demographics? on SAS Programming. 11-24-2022 10:37 AM
- Posted Re: How to randomize Subjects into 2 groups and balance based on demographics? on SAS Programming. 11-24-2022 10:36 AM
- Posted Re: How to randomize Subjects into 2 groups and balance based on demographics? on SAS Programming. 11-24-2022 10:33 AM
- Got a Like for How to randomize Subjects into 2 groups and balance based on demographics?. 11-24-2022 01:26 AM
- Posted How to randomize Subjects into 2 groups and balance based on demographics? on SAS Programming. 11-24-2022 12:27 AM
- Posted Re: Adding MS Word Styles in ODS RTF outputs for overall table of contents on ODS and Base Reporting. 11-08-2021 08:17 PM
- Posted Re: Adding MS Word Styles in ODS RTF outputs for overall table of contents on ODS and Base Reporting. 11-08-2021 08:10 PM
- Posted Adding MS Word Styles in ODS RTF outputs for overall table of contents on ODS and Base Reporting. 11-08-2021 07:11 PM
- Posted Is there a method to code automatically save results as lst file when code is finish running? on SAS Programming. 08-11-2021 09:08 AM
- Posted Re: Proc Report: Across scattered on SAS Programming. 06-26-2020 02:35 PM
- Posted Re: Proc Report: Across scattered on SAS Programming. 06-26-2020 12:59 PM
- Tagged Proc Report: Across scattered on SAS Programming. 06-26-2020 12:57 PM
- Posted Proc Report: Across scattered on SAS Programming. 06-26-2020 12:56 PM
- Posted Re: Retain with multiple first statements on SAS Procedures. 04-22-2020 02:57 PM
- Posted Retain with multiple first statements on SAS Procedures. 04-22-2020 02:39 PM
- Liked Re: Easiest way to extract format values from character variable? for PaigeMiller. 01-21-2020 10:45 AM
- Posted Easiest way to extract format values from character variable? on SAS Programming. 01-21-2020 09:14 AM
-
Posts I Liked
Subject Likes Author Latest Post 1 1 1 1 1 -
My Liked Posts
Subject Likes Posted 1 10-05-2016 11:54 AM 1 11-24-2022 12:27 AM
08-04-2015
03:41 PM
So my code seem to work, but it doesn't seem to save my graph as an image file in the directory I specified. I am unsure how to troubleshoot this and was wondering if anyone can give me some suggestions. So when I goto C:\Graphs, there is nothing there. Does ODS Graphics not work with Proc Gchart? I used the exact ODS graphics and ODS listing code with Proc SGpanel and it works
%macro graph (var);
DATA _null_;
SET fich;
array vars(*) &var;
DO i=1 TO dim(vars);
call symput("mvNAME"||strip(i),strip(vname(vars(i))));
call symput("mvLAB"||strip(i),strip(vlabel(vars(i))));
END;
call symput("mvNB",strip(dim(vars)));
RUN;
%DO b=1 %TO &mvNB;
Title "&&mvLAB&b";
ods graphics on/reset=all imagename="&&mvNAME&b" width=27.8cm height=14cm;
ods listing style=custom2 gpath="c:\Graphs";
proc gchart data=fich;
pie &&mvNAME&b / DISCRETE VALUE=OUTSIDE
PERCENT=OUTSIDE SLICE=OUTSIDE;
run; quit;
ods graphics off;
%end;
%mend graph;
%graph(CS1-CS6);
... View more
05-27-2015
11:00 AM
So I have to do the exact same thing over and over again for multiple dataset, so I figured a macro might be helpful. This is the code I am trying to run.
%macro lab (fich, num);
data &fich;
set &fich;
if CRF&num=" " then CRF&num="MISSING";
%let &num=%eval(&num+1);
if CRF&num=" " then CRF&num="MISSING";
run;
%mend lab;
%lab(temp,55);
%lab(temp1,60);
So basically, I have variables (CRF55, CRF56, CRF57..and so on) that I want it to insert the word "MISSING" when the character value is blank. And then the same thing again for another dataset starting with var CRF60 (so this case will be CRF60, CRF61, CRF62 and so on). I have to do this for 4 varaibles per dataset and all in numerical order (e.g 55,56,57,58 and then another dataset for 60,61,62,63...etc.) Can someone suggests an easy way to do this without manually coding every dataset? The only other solution I can think of is create multiple datasteps and do the %let statement to change the num inbetween each datasets. but I feel there is a more efficient way to code this.
%macro lab (fich, num);
data &fich;
set &fich;
if CRF&num=" " then CRF&num="MISSING";
run;
%let &num=%eval(&num+1);
data &fich;
set &fich;
if CRF&num=" " then CRF&num="MISSING";
run;
%mend lab;
Thank you!!!
... View more
05-01-2015
10:16 AM
thanks that worked for me. I used that to randomly select the men.. and then if the sex variable is missing, i pop recoded that to women.
... View more
05-01-2015
09:39 AM
In my dataset from an actual clinical trial, I have 64 ID numbers (numbered 1 to 64), where 32 goes to treatment group A and 32 goes to treatment B and a score (outcome) So I want to add a hypothetical variable where I want to generate a variable (let's call it Gender/Sex, so 2 levels) that is sex is evenly and randomly distributed within each group (16 males and 16 females per treatment group). How do I do this randomly?
... View more
02-09-2015
03:43 PM
Thanks for this, I was wondering, is there a way for it to work on 9.2 also? So I am on 9.4 but other coders I am working with are on 9.2.
... View more
02-06-2015
12:48 PM
So this is my code thus far:
PROC SGPANEL DATA=new&file;
PANELBY nb/rows=&rows columns=&cols spacing=5 novarname;
VBOX value/category=combined;
FORMAT nb &fmt..;;
%IF %UPCASE(&refline)^= %THEN %DO;
refline &refline / axis=y lineattrs=(pattern=5);
%END;
rowaxis values=(&range) label="&label";
colaxis display=(nolabel);
refline 0 / axis=y;
WHERE &wh;
RUN;
This is the bottom of the output Sadly This is the labels I need to keep for this graph, but I am hoping to make it so it doesn't present it at an angle, but instead multiple lines.. I was told I should split the character label, but I have no idea how to do that. I did find the splitchar statement (SPLITCHAR=“character-list") within the SAS documentation, but I can't find examples on how to apply it. I am unsure if this is the right statement that I should use to make it the way I want it. Does anyone have any ideas?
... View more
01-09-2015
09:31 AM
Thanks I'll look into Proc GLM. Yes there is more than 4 observations in my dataset shown Can I use the class statement to set the reference value for Proc GLM?
... View more
01-09-2015
09:09 AM
Dataset ID Y X1 (Categorical) X2 (categorical) 1 85 2 1 2 156 4 5 3 78 1 8 4 456 3 9 1) I think by default, proc reg selects the lowest values as the reference variable right? In this case the reference value of X1/X2 will be 1. If I were to run:
Proc reg data=have;
model y=x1 x2;
run;
2) If I wanted the reference value to be 2 for the X1 variable, how do I do it?
... View more
01-08-2015
01:06 PM
So this is what I have right now
proc format;
value namefmt 1="Experiment" 2="Control";
run;
data have;
input name count;
datalines;
1 16
2 8
;
run;
data have;
set have;
format name namefmt.;
run;
data want;
set have;
wantvar=name||" (N="||count||")";
run;
So in my want database, my wantvar is showing up as "1 (N= 16)", where I want it to actually show up as "Experiment (N=16)". How can I get it to show the formatted value and not the actual value without creating a new variable?
... View more
12-18-2014
09:26 AM
I have this sample dataset and want to identify the variable with either the highest or lowest value. So in this case not to report the value but report the variable. Does anyone have any suggestions on how to do this? ID Var1 Var2 Var3 WANT_Lowest WANT_Highest 1 20 50 30 Var1 Var2 2 0.90 0.25 0.10 Var3 Var1 So I want these two variables. As we can see with ID=1, the highest value is Var2 so the WANT_highest is coded Var2. Similaringly with the lowest for Var1. What is the easiest way to do this? I know the max/min function will return the values. But in this case I want it to return the variable name.
... View more
12-17-2014
08:55 AM
So I have this sample data format ID Block Value WANT 1 A -10 1 1 A 0 2 1 A 0.52 3 1 A 18 4 1 A 20 5 1 A 25 6 1 b -19 1 1 b 0.25 2 1 b 0.96 3 1 b 21 4 1 b 32 5 1 b 45 6 So I want to code a rank based on the values for each ID/block. All patients have 12 records (6 for block A and 6 for block B). So I did the first step where I used proc sort by ID Block and Value. Now I want to create that WANT variable where it indicates the rank within each ID/Block. What is the easiest way to do this? Thanks!
... View more
11-18-2014
01:10 PM
Thanks for this.. so with this, I can change the libname and the memname with my active dataset right? And with the call execute, will this run the sgpanel for all the variables in the dataset, since there is no "list" in dataset?
... View more
11-18-2014
11:46 AM
Basically I am running 200 boxplots.. So I have all the variable name in a list, since I added them in the keep statement in my dataset) this is the macro: %macro %somemacro(var); proc sgpanel data=dataset; panelby visit/rows=1 columns=3 spacing=5 novarname; vbox &var / category=subgrp; rowaxis values=(0 to 100 by 20); run; %mend somemacro;
... View more
11-18-2014
11:06 AM
So is there a way to make an array work outside of the data statement? So basically I have to run this: I have to run the following macro for 200 variables: %macro %somemacro(var); proc sgpanel data=dataset; panelby visit/rows=1 columns=3 spacing=5 novarname; vbox &var / category=subgrp; rowaxis values=(0 to 100 by 20); run; %mend somemacro; The variables are not in numerical order so I can't do a regular do loop. For example a few variables: race, aduPH, BMI)... I thought an array would be helpful for this situation but I I think it is only for the data statement. SO I am wondering if there is a more efficient solution? This is what I have tried: array adu{*} race bmi aduPH aduFEEL aduVIEW aduSPORT; do i=1 to dim(adu); %somemacro(adu(i)); end;
... View more
10-09-2014
12:37 PM
I am trying to think about a solution. We have multiple computers with SAS on it, some have 9.4 64 bit while others have 9.2 32 bit. We have recently notice there are issues with the formatting between these two versions when opening datasets. So what I proposed as a solution is add the %include statement to load the format.sas file when loading our projects into SAS (we have an autoexec file for every project). This will reload the format every time for the computer the person is using (32 vs 64 bit). But the downside on that is if the formats.sas file does not exist (typically during early stages of the project), an error message will show up in the log. Our protocol is quite strict where we cannot have any error messages in the logs, even temporary ones. I am wondering if there is a solution where we can reformats program file only if it exist, so there is not error message in the log file. Or if anyone can suggest any alternatives so the formats would work on both 32 and 64 bits.
... View more