BookmarkSubscribeRSS Feed
sasnewbie5
Fluorite | Level 6

I need to create a new variable that contains the first and last name from my dataset. The code I have is as follows:

data hw9.combo;
	infile "/folders/myfolders/hw9/combo";
	input name = firstname + lastname;
run;

I get the following errors when trying to run it:

NOTE: Variable lastname is uninitialized.
ERROR: Physical file does not exist, /folders/myfolders/hw9/combo.
 
Can anyone help me resolve this? I'm using SAS university edition, which is why I did the file location that way.
3 REPLIES 3
r_behata
Barite | Level 11

Hello @sasnewbie5 . Please look into this video, it may be a good reference point for importing external data into SAS.

 

https://video.sas.com/detail/video/4573016758001/creating-a-sas-table-from-a-csv-file

 

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

 

@sasnewbie5 wrote

data hw9.combo;

infile "/folders/myfolders/hw9/combo";

input name = firstname + lastname;

run;

we don't add character variables.

 

one way to create a new variable name would be

name = firstname || ' ' || lastname;

 

 

 

ballardw
Super User

First thing will be to get the name of the file to read correct.

Second while + is acceptable on an input statement it is used to move a read pointer. The = would not be.

Read the variables then manipulate them.

 

 

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

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1114 views
  • 0 likes
  • 4 in conversation