Hello,
I have a sample dataset below. Two questions; first, the ")" are missing in all the data lines, not sure how to fix it; second, my Proc transpose codes are not working. Please help; thanks.
data Mean_Median_Output;
input House 1.0 LOS_Mean_Q1Q3 $ LOS_Median_range $ Age_Mean_Q1Q3 $ Age_Median_range $;
infile datalines delimiter='/';
datalines;
0/2.2 (1-2)/1.0 (0-92)/3.7 (2-4)/2.0 (2-17)/
1/2.9 (1-3)/2.0 (0-117)/6.6 (3-9)/5.0 (2-17)/
;
run;
Proc transpose data=Mean_Median_Output out=Mean_Median_transpose prefix=House_; run;
Hello @ybz12003,
Use a LENGTH statement or informats (as shown in the example below) to specify sufficient lengths for your character variables. Just using the dollar sign in the INPUT statement means a default length of 8 bytes.
input House (LOS_Mean_Q1Q3 LOS_Median_range Age_Mean_Q1Q3 Age_Median_range) (:$13.);
I guess that you want to add these ID and VAR statements to your PROC TRANSPOSE step:
proc transpose data=Mean_Median_Output out=Mean_Median_transpose prefix=House_; id house; var _char_; run;
Variables defaults to 8 in lenght, specifying a length of 9 should fix the truncation problem.
What is your specific problem with PROC TRANSPOSE?
For missing ")" - set proper variable LENGTH:
data Mean_Median_Output;
LENGTH House 8 LOS_Mean_Q1Q3 LOS_Median_range Age_Mean_Q1Q3 Age_Median_range $ 30;
input House 1.0 LOS_Mean_Q1Q3 $ LOS_Median_range $ Age_Mean_Q1Q3 $ Age_Median_range $;
infile datalines delimiter='/';
datalines;
0/2.2 (1-2)/1.0 (0-92)/3.7 (2-4)/2.0 (2-17)/
1/2.9 (1-3)/2.0 (0-117)/6.6 (3-9)/5.0 (2-17)/
;
run;
proc print;
run;
For transpose - what output do you expect to get?
Bart
Hello @ybz12003,
Use a LENGTH statement or informats (as shown in the example below) to specify sufficient lengths for your character variables. Just using the dollar sign in the INPUT statement means a default length of 8 bytes.
input House (LOS_Mean_Q1Q3 LOS_Median_range Age_Mean_Q1Q3 Age_Median_range) (:$13.);
I guess that you want to add these ID and VAR statements to your PROC TRANSPOSE step:
proc transpose data=Mean_Median_Output out=Mean_Median_transpose prefix=House_; id house; var _char_; run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.