BookmarkSubscribeRSS Feed
deleted_user
Not applicable
how to get the output of this program. I am unable to get output.

data abc;
input pid name $ age race $;
cardsl
101 rakesh kumar 34 asian
102 hari 29 african
;
4 REPLIES 4
Oleg_L
Obsidian | Level 7
I'm also having a difficulties with your sample data.
The variable name in the first row consists of two parts, but in the second row the second part is missing.
Don't you miss something? Does your actual data as inconsistent as you post it?

[pre]
data abc;
infile cards missover;
input pid fname :$30. sname :$30. age race :$10.;
cards;
101 rakesh kumar 34 asian
102 hari Sname_is_missing 29 african
;
[/pre]
deleted_user
Not applicable
No missing data is there.I have to display in name column as rakesh kumar and hari without keeping Sname_is_missing.
Oleg_L
Obsidian | Level 7
The code below is a solution from this forum poster "Data _null_".

http://support.sas.com/forums/thread.jspa?messageID=51217접

>
http://support.sas.com/forums/thread.jspa?messageID=51217접



[pre]

data a;
retain dlm ' ';
infile cards truncover dsd dlm=dlm;
input @;
end = length(_infile_)+1;
do j = 1 to 2;
end = find(_infile_,dlm,-(end-1));
end;
start = find(_infile_,dlm,1);
length = end-start-1;
input pid :8. name $varying50. length +1 age :8. race :$10.;
keep pid name age race;
cards;
101 rakesh kumar 34 asian
102 hari 29 african
;



[/pre]

Message was edited by: Oleg_L

Message was edited by: Oleg_L Message was edited by: Oleg_L
Ksharp
Super User
It is interesting.Ok, Let's overcome it.


[pre]
data temp;
infile datalines truncover;
input pid remain $100.;
name=substr(remain,1,anydigit(remain)-1);
age=scan(remain,-2);
race=scan(remain,-1);
drop remain;
datalines;
101 rakesh kumar 34 asian
102 hari 29 african
;
run;
[/pre]


Ksharp

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 671 views
  • 0 likes
  • 3 in conversation