BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Gregorytus07
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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).

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

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).

Gregorytus07
Fluorite | Level 6

@Tom 

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

 

Gregorytus07_0-1658095238582.png

 

I am not sure of how to fix this. Thanks in advance.

 

Best regards,

Festus.

Tom
Super User Tom
Super User

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.

Gregorytus07
Fluorite | Level 6

@Tom 

Thanks a lot, it worked!

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 652 views
  • 2 likes
  • 2 in conversation