Thanks for all your comments
I checked the link with macro-step to create data in presentable, but honestly I cound even not get that working.
The data Im using is confidential, but I've taken 5 patients information and changed all which is referable. Now its anonoumys and can be reproduced by you.
The data is now presented in long format as a CSV file.
I also tried to change my variable names using number as suffix to shorten the code, and that helped . Thanks 😄
With ordinary English words what Im trying.
- collect data for each patient compromised (Im not sure wide dataset is best, but I tried that with merge step because I was advised to), so I can make analyses.
- Data includes 5 patient (record_id 1-5).
- Each patient can have several implantations (impl_id). For each implantation there is corresponding data from the same operation, which is in redcap_repeat_instrument called generator and lead. A patient might have only one implantation with corresponding generator and multiple lead informations.
Only id is common for those three instruments (implantatation + generator + lead) . The id names:
implantatation + generator + lead
the name of variable: impl_id idimpl idimpl_2
I would like to make sure the date of implantation is copied to generator and lead data without loosing the corresponding data for that lead. (with long data each lead has its own row with all necessary information)
As you saw from the code yesterday I was creating a new column called gen_date_X and the same for lead information.
data seventhgen; set output_data;
where redcap_repeat_instrument = "generator" and redcap_repeat_instance = 7;
idpatient = idpatient_3;
keep idpatient Idimpl Idimpl7 gentype gentype7 gensite gensite7 genprevsite genprevsite7 genstatus genstatus7
genexpdate genexpdate7 genreason genreason7 genprocedure genprocedure7 gen_date_7;
rename
Idimpl = Idimpl7
gentype = gentype7
gensite = gensite7
genprevsite = genprevsite7
genstatus = genstatus7
genexpdate = genexpdate7
genreason = genreason7
genprocedure = genprocedure7;
gen_date_7 = "";
run;
I thougt I could use if and then statement. But as I have 11 implantations, 10 generators and 15 leads, I cant be sure they find each other correctly.
one impl_id (from implantation information) can be equal to 2 lead information.
I would like:
If impl_idX = idimplX then gen_dateX = impl_dateX
I then need them to be in chronologic order for lead, generator and implantion data, as I need to divide my cohort in patients with "first" lead beeing transvenous, endocardial, subcutaenous or unknown.
To this purpose I made som small coding to classify each lead information in above mentioned groups according to variables: manufacture_2, modelname_2 and modelnumber_2.
When I doubblechecked my code for the classifying of groups, I found out I need all the lead information with date to order them chronologically.
I used this:
proc print data = ana2;
where implprtype1 = "First";
run;
As seen here, 23+4 patients does not have this lead beeing the first.
I cant assume all information on lead with suffix 1 neccesarily really was their shirt implantation. To solve this I wanted to create this date column to generator and lead information.
The reason why I thought changing the set to wide is I could not see how to get SAS to read in different lines to search for information.
Tried with proc sql to gather the information, but as you can understand, Im really new to this.
Im not even sure the ordering of task is correct
The main task is to compare outcomes of 4 different groups. I have to divide the patients based on their first leads to characterize the groups before comparing endpoints ..
Hope it got a bit more clear ?
... View more