🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 02-07-2022 04:31 AM
(1112 views)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
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