When changing the name of a dataset using a datastep to further manipulate the dataset, I see that some of the variables pos have changed. This results in some of the values shifting to the wrong variables.
How can I prevent changes other than the dataset's name when performing the following steps?
DATA want;
SET have;
RUN;
Thanks,
Adam
In my experience with SAS, what you describe does not happen. Please post a reproducible example.
Here is a screen shot of the dataset before and after the datastep. A value seems to be appear in the first collumn. Below are the output of the Proc Contents for the two datasets. Note how the position changes for some variables.
LAB1 Proc Contents
BIOMEDIC Proc Contents:
Very confusing! Nothing matches after a simple copy operation? What is your theory as to what might have happened?
My original file might be carrying some value from previous manipulations (ex, Retain), hidden values, or be corrupted. I have no idea. Thanks for confirming this is abnormal.
@Adambo wrote:
My original file might be carrying some value from previous manipulations (ex, Retain), hidden values, or be corrupted. I have no idea. Thanks for confirming this is abnormal.
That doesn't make sense.
If the code is as shown, with no retain or any other process in between the position in the buffer shouldn't change. Note that your variable order is staying the same.
Can you post the code that causes including the proc contents before and after?
If you can replicate it I would contact SAS Tech Support.
Not sure what version your on, but In SAS 9.4 POS isn't even included in the output from proc contents, there's a NPOS though.
Someone else created the file i'm working on. I don't know what specific manipulations were done before it got to me.
@Adambo wrote:
Someone else created the file i'm working on. I don't know what specific manipulations were done before it got to me.
Those don't matter, they're not maintained with the dataset.
What matters is what you're doing. Are you seeing a note in log? About CEDA access perhaps?
Please post the code and log.
6635 DATA SAS.BIOMEDIC;
6636 SET SAS.LAB1;
6637 RUN;
NOTE: 51588 observations were read from "SAS.LAB1"
NOTE: Data set "SAS.BIOMEDIC" has 51588 observation(s) and 32 variable(s)
NOTE: The data step took :
real time : 0.118
cpu time : 0.109
6638 quit; run;
6639 ODS _ALL_ CLOSE;
POS -> Position in Buffer
NUMBER -> Position in Dataset
This results in some of the values shifting to the wrong variables.
According to Proc Compare output all variables and values are identical.
Personally, I don't see an issue. If you want to understand why the location in the buffer has changed it could be as simple as you're writing the data to a different system. I would consider asking tech support for an answer if interested, but given everything provided the change in POS should not impact your work.
Please run the compare procedure:
Proc compare data=LAB1 compare=BIOMEDIC;
ID I_LABIM_KITID;
run;
Look at the output of this procedure. Are there unequal values ?
If you don't understand the output report, post it and I shall try to clarify it.
You should not be aware of changes in posions of variables, as long as all observations are equal.
Shmuel
The PROC COMPARE proves that the 2 datasets are identical as far as column names and values are concerned which is what you would expect. It doesn't explain the change in column positions.
Clarification of results:
You got the note thal all observations are duplicate, that is because I_LABIM_KITID is not a unique key.
Change the ID line and add the other key varables in a format of: ID key1 key2 key3 ... ;
You got also the message "Nomber of Observations with Some Compared Variables Unequal = 0" and
"Nomber of Observations with All Compared Variables Equal = 51588" which is the whole dataset.
Those 2 messages are the proof that the 2 datasets are equal by values.
Regards, Shmuel
I tried Proc Compare with different KeyIDs. I thought this would not work as the KeyID values are different in the two datasets (as displayed to me) but it appears SAS still sees them as the same regardless.
So I reckon the two datasets are "technically" the same. So I guess this is something related to the display and my system.
I reckon the two datasets are "technically" the same. So I guess this is something related to the display provided by my system.
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!
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.