BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
nilesh1985
Calcite | Level 5

Hi,

 

Environment : SAS ODAMID/ SAS Studio

 

I am trying to create a dataset using datalines, wherein one of the columns has leading spaces. I want to keep the leading spaces in the created dataset which is not happening by default.

Would appreciate any help. Thanks in advance.

Example 

data exp3;
infile datalines delimiter=",";
INPUT SNO :8. cat :$150.;
datalines;
1, main category
2, sub category
;
run;

Output (Default) 

1|main category
2|sub category

Desired Output
1|        main category
2|              sub category
 
Regards,
Nilesh
 
1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

It's an informat thing. Use the $Charw. instead like this

 

data exp3;
infile datalines delimiter=","; 
INPUT SNO :8. cat :$char150.;
datalines;
1,     main category
2,         sub category
;
run;

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

It's an informat thing. Use the $Charw. instead like this

 

data exp3;
infile datalines delimiter=","; 
INPUT SNO :8. cat :$char150.;
datalines;
1,     main category
2,         sub category
;
run;
nilesh1985
Calcite | Level 5
On the same lines need some more clarification:-
data exp3;
infile datalines delimiter=",";
INPUT SNO :8. cat :$char150.;
datalines;
1, main category 1 - orthopedics
2, sub category
3, main category sub 2 - hemotology
4, sub category 2
;
run;

If I manually align the sub category to come below the - of main category it gets automatically aligned with less spacing, but if i put any other character like '*' in place of space, then it works.

Reason being i am trying to create a template for report.

Any help would be appreciated.

Regards,
Nilesh

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 803 views
  • 2 likes
  • 2 in conversation