here is the deal: I am creating a table with some variables and the 'observations' are read from a .txt file here is my code f
data pesek;
infile 'a path'
input id kon $ alder utb $@@;
run;
ok that works out fine however it is adding a blankspace to each observation in my variable 'utb' which is a problem. If I now add data to this existing table with the INPUT statement for example I add: 29 M 20 GY it will not create extra blankspace to GY which means that any observation in my table which has GY+blankspace will not be "the same" as the GY which I added with the input statement since one has the blankspace and the other one doesnt
what can I do?
It is very hard to resolve a data reading issue without example data. Provide a few lines of data.
Also, how are you "adding" data? Append, merge, update or something else? I'm pretty sure I don't understand your limitation/problem as stated.
It sounds like you have a few misconceptions. Consider these basic concepts.
Both KON and UTB have a length of 8 characters. That's the default length assigned for the style of INPUT statement that you are using.
When you refer to a variable, trailing blanks don't matter. These statements always find the same matches:
if utb='GY' then do;
if utb='GY ' then do;
When SAS detects that it is comparing character strings that have different lengths, it automatically pads the shorter string with blanks to make the lengths equal. (That is, for purposes of making the comparison ... it is not actually changing the values of any variables.)
Does that change the questions that you want to ask?
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.
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.