BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dustychair
Pyrite | Level 9

Hi everyone,

I want to change value of "N" to blank in one of variables in my data. I used the code below but I did not get any results and I think that code is replacing values with "." I could not find what I'm missing.

 

Thanks

 

proc export data=model
outfile= "C:\data_reading.txt"
DBMS=tab replace; putnames=no;
run;


data reading1;
set data_reading;
if Reading_Raw_Scores=N then call missing (of Reading_Raw_Scores);
run;

*******************

my data:

 

5854378 1111NNNNNNNNNNNNNNN111101111001NNNNNNNNNNNN
6710686 1000001000000100000NNNNNNNNNNNNNNNNNNNNNNNN
5789905 1111NNNNNNNNNNNNNNN111111111111NNNNNNNNNNNN
6169024 1111NNNNNNNNNNNNNNN111110111111NNNNNNNNNNNN
6966627 1000100000110000010NNNNNNNNNNNNNNNNNNNNNNNN
6530308 1011NNNNNNNNNNNNNNN111101100111NNNNNNNNNNNN
6530613 1000NNNNNNNNNNNNNNN110100111010NNNNNNNNNNNN
5585170 1111NNNNNNNNNNNNNNN111111101111NNNNNNNNNNNN
6427927 1010111111100011110NNNNNNNNNNNNNNNNNNNNNNNN
5994414 0101001011000001111NNNNNNNNNNNNNNNNNNNNNNNN
6244942 1101NNNNNNNNNNNNNNN010000100001NNNNNNNNNNNN
4911740 1111NNNNNNNNNNNNNNN111101110110NNNNNNNNNNNN
5845509 1111NNNNNNNNNNNNNNN100000110100NNNNNNNNNNNN
4905478 1000011110011011010NNNNNNNNNNNNNNNNNNNNNNNN
5244869 1110NNNNNNNNNNNNNNN001100100101NNNNNNNNNNNN
5654158 1110NNNNNNNNNNNNNNN110000000101NNNNNNNNNNNN
6012869 1110NNNNNNNNNNNNNNN010111000000NNNNNNNNNNNN
4943032 1100011111111111111NNNNNNNNNNNNNNNNNNNNNNNN
5233136 1101NNNNNNNNNNNNNNN110110100001NNNNNNNNNNNN

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

are you looking to translate?

 

data w;
Reading_Raw_Scores='1111NNNNNNNNNNNNNNN111101111001NNNNNNNNNNNN';
Reading_Raw_Scores=translate(Reading_Raw_Scores,' ','N');
run;

View solution in original post

5 REPLIES 5
novinosrin
Tourmaline | Level 20

are you looking to translate?

 

data w;
Reading_Raw_Scores='1111NNNNNNNNNNNNNNN111101111001NNNNNNNNNNNN';
Reading_Raw_Scores=translate(Reading_Raw_Scores,' ','N');
run;
dustychair
Pyrite | Level 9

Yes, it worked.

Many thanks

data_null__
Jade | Level 19

Do you want to read 43 responses into separate variables?

 

Another example using the MISSING statement.

 

data scores;
   missing n;
   input id:7. (q1-q43)(1.);
   cards;
5854378 1111NNNNNNNNNNNNNNN111101111001NNNNNNNNNNNN
6710686 1000001000000100000NNNNNNNNNNNNNNNNNNNNNNNN
5789905 1111NNNNNNNNNNNNNNN111111111111NNNNNNNNNNNN
6169024 1111NNNNNNNNNNNNNNN111110111111NNNNNNNNNNNN
6966627 1000100000110000010NNNNNNNNNNNNNNNNNNNNNNNN
6530308 1011NNNNNNNNNNNNNNN111101100111NNNNNNNNNNNN
6530613 1000NNNNNNNNNNNNNNN110100111010NNNNNNNNNNNN
5585170 1111NNNNNNNNNNNNNNN111111101111NNNNNNNNNNNN
6427927 1010111111100011110NNNNNNNNNNNNNNNNNNNNNNNN
5994414 0101001011000001111NNNNNNNNNNNNNNNNNNNNNNNN
6244942 1101NNNNNNNNNNNNNNN010000100001NNNNNNNNNNNN
4911740 1111NNNNNNNNNNNNNNN111101110110NNNNNNNNNNNN
5845509 1111NNNNNNNNNNNNNNN100000110100NNNNNNNNNNNN
4905478 1000011110011011010NNNNNNNNNNNNNNNNNNNNNNNN
5244869 1110NNNNNNNNNNNNNNN001100100101NNNNNNNNNNNN
5654158 1110NNNNNNNNNNNNNNN110000000101NNNNNNNNNNNN
6012869 1110NNNNNNNNNNNNNNN010111000000NNNNNNNNNNNN
4943032 1100011111111111111NNNNNNNNNNNNNNNNNNNNNNNN
5233136 1101NNNNNNNNNNNNNNN110110100001NNNNNNNNNNNN
;;;;
   run;
proc print;
   run;
dustychair
Pyrite | Level 9

Hi data_null__,

it sets each value to separate variables but still N is there.

data_null__
Jade | Level 19

Missing N one of the 27 special missing values ._ .A-.Z

 

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 6004 views
  • 1 like
  • 3 in conversation