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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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