Hi all,
I create a table using a proc sql:
PROC SQL; CREATE TABLE A (B char(6) label = "BA"); QUIT;
For every rows, the column B is filled in with "PA".
Finally the column B of my table A has a length of 2.
I would like it to remain to 6 as I ask it to do...because in a next step I merge with another table which has more than 2 characters and otherwise it creates truncation problems.
Do you know how I could do it?
Thanks
Add a length statement.
PROC SQL;
CREATE TABLE A
(B char(6) label = "BA" length=8);
QUIT;
@FP12 wrote:
But why did you write 8? I want 6! ^^
Then change it to 6.
@FP12 wrote:
I tried it and the problem remains.
Show what you tried and what the 'problem remains' means. Explain in detail, preferably using the example/code we can run. It works in the demonstration code I presented so either you're not stating something that's important or doing something else that's changing it somewhere else.
The output here clearly shows the length is now 8.
SAS Output
| Alphabetic List of Variables and Attributes | ||||
|---|---|---|---|---|
| # | Variable | Type | Len | Label |
| 1 | B | Char | 8 | BA |
PROC SQL;
CREATE TABLE A
(B char(6) label = "BA" length=8);
QUIT;
proc contents data=a;
run;
You are obviously skipping something very important as there are no values for B shown. The empty data set created by the shown SQL does have a length of 6.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.