DATA Step, Macro, Functions and more

I have a Variable which as both Num and Char values but it is defined as Num

Reply
Contributor
Posts: 46

I have a Variable which as both Num and Char values but it is defined as Num

Hi,

I have a variable TERR which as both NUM and Char values such as first 10 obs as 1215, 1216.........1225 and then other 10 obs as PDS1 PDS2.....PDS10. But it is defined as Num and the other obs with PDS1-PDS10 are displayed as dot. I tried converting to char but I still see them missing. How can I get the Values for last 10 obs (PDS1-PDS10) in my data?

 

Here's my code to conversion:

data Sams1;

set sam (rename=(Terr=Terr1));

Terr=put(Terr1,7.);

drop Terr1;

run;

 

Thank you

Malathi

Super User
Posts: 5,260

Re: I have a Variable which as both Num and Char values but it is defined as Num

Defined as NUM, by whom?

If you got mixed datatypes, stick to CHAR.

If your data haven't been modelled properly, you may need to restructure your data set.

Data never sleeps
Super User
Posts: 10,538

Re: I have a Variable which as both Num and Char values but it is defined as Num

You will need to go back to however you brought the data into SAS. Once SAS considered the variable as numeric anything not actually a valid number was set to missing. The solution is likely going to involve going back to the process that was used to bring the data into SAS and modifying it so all of the original values are retained.

 

The single most common cause of this confusion is using Proc Import to bring data into SAS. The procedure has to make "guesses" as to what the values should be and depending on the data source only a few rows of the data are examined to make those guesses. The defualt is the first 20 rows. For some file formats such as CSV there is an option to set GUESSINGROWS (note the name of the option) to use up to 32767 rows.

Contributor
Posts: 46

Re: I have a Variable which as both Num and Char values but it is defined as Num

Thank you, I made the changes in the excel and it worked.

 

Malathi

Ask a Question
Discussion stats
  • 3 replies
  • 105 views
  • 0 likes
  • 3 in conversation