BookmarkSubscribeRSS Feed
jimmychoi
Obsidian | Level 7

Hi,

 

To add a new numeric column with default value (null) to an existing dataset, which was imported using proc import, from xlsx file,

i thought this might work:

data alldeals2;	
	set alldeals;
	'% Acquired'n = .;
	'Debt Invested (in USD)'n = .;
	'Equity Invested (in USD)'n = .;
	'Bid Premium'n = .;
	'Per-share price'n = .;
	'Deal Summary'n = '';
	'Therapeutic Category'n = '';
	'Last Update'n = .;
run;

When I run the code, variables initialized with numeric null (.) are character types. why ?

I even tried this way:

'% Acquired'n = input('% Acquired'n, COMMA14.2);

but didn't work.

Please help me to make a new & null numeric variable.

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Are these variables you are trying to create already in the data set ALLDEALS?

--
Paige Miller
PaigeMiller
Diamond | Level 26

If I remove the SET ALLDEALS; from your code, then try creating one of your variables, what does PROC CONTENTS say? It says the variable is numeric. So the command SET ALLDEALS; must be interfering somehow.

 

data alldeals2;	
	'% Acquired'n = .;
run;

proc contents data=alldeals2;
run;
Alphabetic List of Variables and Attributes

#    Variable      Type    Len

1    % Acquired    Num       8

--
Paige Miller
andreas_lds
Jade | Level 19

First thing you should do: remove all special chars from all variable names and stick to the normal 26 letters, the underscore and numbers. Anything else must be moved to label, to maintain readable and maintainable code.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3162 views
  • 2 likes
  • 3 in conversation