Hi everyone,
I am trying to proc transpose two variables at the same time using the SAS code below:
proc sql noprint;
select max(obs) into :obs from(select count(*) as obs from ccv_dc1 group by study_id);
quit;
proc summary data=ccv_dc1 nway;
class study_id;
output out=ccv_dc2(drop=_:) idgroup(out[&obs] (VERT_DXCCSR_label_DC VERT_cate_prefix_label_DC)=);
run;
However, there is an error message in the log that states: The parameter value 116 is not within the required range of 1 and 100.
I read online that the max number of observations for each ID cannot exceed 100 when using my code above. I need help with a code that can accommodate more than 100 observations for each ID.
Best regards,
Festus.
Why would you want to create a structure that as 332 variables?
What can you possibly do with such a structure?
Just use any other method.
proc sql noprint;
select max(obs) into :obs from(select count(*) as obs from ccv_dc1 group by study_id);
quit;
data ccv_dc2 ;
do _n_=2 by 1 until(last.study_id);
set ccv_dci;
by study_id;
array _x1 VERT_DXCCSR_label_DC VERT_DXCCSR_label_DC1-VERT_DXCCSR_label_DC&obs ;
array _x2 VERT_cate_prefix_label_DC VERT_cate_prefix_label_DC1-VERT_cate_prefix_label_DC&obs;
_x1[_n_] = VERT_DXCCSR_label_DC;
_x2[_n_] = VERT_cate_prefix_label_DC ;
end;
keep study_id VERT_DXCCSR_label_DC1-VERT_DXCCSR_label_DC&obs VERT_cate_prefix_label_DC1-VERT_cate_prefix_label_DC&obs ;
run;
You might have to sort your CCV_DCI dataset by STUDY_ID (or at least index it).
Why would you want to create a structure that as 332 variables?
What can you possibly do with such a structure?
Just use any other method.
proc sql noprint;
select max(obs) into :obs from(select count(*) as obs from ccv_dc1 group by study_id);
quit;
data ccv_dc2 ;
do _n_=2 by 1 until(last.study_id);
set ccv_dci;
by study_id;
array _x1 VERT_DXCCSR_label_DC VERT_DXCCSR_label_DC1-VERT_DXCCSR_label_DC&obs ;
array _x2 VERT_cate_prefix_label_DC VERT_cate_prefix_label_DC1-VERT_cate_prefix_label_DC&obs;
_x1[_n_] = VERT_DXCCSR_label_DC;
_x2[_n_] = VERT_cate_prefix_label_DC ;
end;
keep study_id VERT_DXCCSR_label_DC1-VERT_DXCCSR_label_DC&obs VERT_cate_prefix_label_DC1-VERT_cate_prefix_label_DC&obs ;
run;
You might have to sort your CCV_DCI dataset by STUDY_ID (or at least index it).
Thanks for your help!
The variables are ICD-10-CM codes. Some IDs have above 100 unique ICD-10 codes.
I sorted the dataset as advised and ran the code. However, I got this in the log output
I am not sure of how to fix this. Thanks in advance.
Best regards,
Festus.
Don't insert leading spaces into the macro variable with the count.
Either exclude them when making the macro variable by adding the TRIMMED keyword.
into :obs trimmed
Or just add a %LET statement to remove them.
%let obs=&obs;
Do NOT post PICTURES of TEXT in this forum. Copy the text and paste it into the text box opened by the Insert Code button on the editor icon bar.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.