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

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;
1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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;

View solution in original post

3 REPLIES 3
LinusH
Tourmaline | Level 20

Variables defaults to 8 in lenght, specifying a length of 9 should fix the truncation problem.

 

What is your specific problem with PROC TRANSPOSE?

Data never sleeps
yabwon
Amethyst | Level 16

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



FreelanceReinh
Jade | Level 19

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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1443 views
  • 3 likes
  • 4 in conversation