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
Meteorite | Level 14

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;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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