When I try to get the size of a char variable, I have to return the size plus 1.
The variable size is wrong !!!
This is a bug ?
More details in file atached ..
Notice the HEX shows this. 09 - which is tab - at the front of every variable.
What happens if you use a HEX Format on the variable?
I suspect there's a 'invisible blank' in your data somehow.
Thanks, I did try resset the code and data, but the problem not resolved yet.
I await for solution ..
I suspect the extra 1 is the Windows end of line character. On Demand is Unix system.
Hi:
When you code the NAME $20. in the INPUT statement, you are probably reading the end of record marker for the DATALINES. There is a very simple way to change that. Please see the attached examples. Altering your INPUT statement and adding a LENGTH statement results in both operating systems having the same length, as shown below.
Basically, the LENGTH statement specifies the MAXIMUM length for the variable and establishes the size of the variable in the descriptor portion of the dataset and the simplified LIST input statement (INPUT NAME $;) instructs SAS to read until a space (the default delimiter is encountered or the end of record mark is encountered.
cynthia
The code below is with < TAB >
code without <TAB>
Now, works correctly
You are correct !!!
The problem was have Displaced this items in editor with the < TAB >, when I move left this items to left with <BACKSPACE> this problem was resolved.
Thank you very much ...
Notice the HEX shows this. 09 - which is tab - at the front of every variable.
I can't replicate your issue on On Demand. I did test it SAS On Demand, not SAS UE or SAS Studio installed on my desktop.
I get the correct values, but I'm on a Unix system (a Mac). I strongly suspect the invisible character issue mentioned earlier. Post the output using the hex editor. I've added the relevant code below.
In the future post your output directly into the forum, not with an attachment, many users won't bother to download an attachment so it takes longer to get answers since they simply won't respond or will wait for you to post directly to the forum.
data WRONG_LENGTH;
Input Name $20. ;
v_length=length(name) ;
y=put(name, hex20.);
datalines ;
Anna
Christopher
Mary
Jonathan
Tim
Elizabeth
Amy
schwarzenegger
Kevin
Porter
;
RUN ;
In your word doc it looks like you have TABS at the beginning of your data lines.
datalines;
Anna
Christopher
;
You can probably avoid making this mistake again if you remember to always start the DATALINES (or CARDS) statement in column one so the SAS editor will default to starting the actual lines of data in column one also.
datalines;
Anna
Christopher
;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.