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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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