Hi! I was trying to read in a data set into SAS, but I ran into the following issue in my log:
WARNING: Some character data was lost during transcoding in column: sq105j_s at obs 3739.
WARNING: Some character data was lost during transcoding in column: sh102c at obs 14322.
WARNING: Some character data was lost during transcoding in column: db107_s at obs 16615.
WARNING: Some character data was lost during transcoding in column: ue115b at obs 21310.
I want to print out the data set and reference those observation numbers to see why those particular observations have issues.
How would I go about referring to the observation number in my SAS code (I know there is a built in SAS variable for observation number)? When I tried utilizing the _N_ variable, it didn't seem to work. Any input regarding this would be much appreciated! Thanks so much!
It really depends on what code you ran that produced those notes.
If you just did something simple like:
data want;
set have;
run;
Then you could use the _N_ automatic variable in another data step to filter to just the observations mentioned in the log.
data problems ;
set have;
if _n_ in (3739 14322 16615 21310);
run;
But to really see what was in that data that caused the transcoding issue you will want to read it without transcoding. So you might want to add ENCODING=ANY dataset option.
data problems ;
set have (encoding=any);
if _n_ in (3739 14322 16615 21310);
run;
It really depends on what code you ran that produced those notes.
If you just did something simple like:
data want;
set have;
run;
Then you could use the _N_ automatic variable in another data step to filter to just the observations mentioned in the log.
data problems ;
set have;
if _n_ in (3739 14322 16615 21310);
run;
But to really see what was in that data that caused the transcoding issue you will want to read it without transcoding. So you might want to add ENCODING=ANY dataset option.
data problems ;
set have (encoding=any);
if _n_ in (3739 14322 16615 21310);
run;
Thanks so much for your help @Tom !
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.