BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ybz12003
Rhodochrosite | Level 12

Hello,

I would like to insert additional numbers between the values in my sample dataset with a 1-unit interval.  Please help, thanks.

 

data HAVE;  
	Format Weekcode 4.0 Test 3.0 Pos 3.0 Lab 4.0; 
	infile datalines delimiter='/'; 
	input Weekcode Test Pos Lab;  
	datalines;                     
2102/ 8/ 3/ 256/
2103/ 3/ 1/ 619/
2106/ 5/ 2/ 2066/
2107/ 3/ 0/ 256/
2110/ 7/ 6/ 619/
;  

data WANT;  
	Format Weekcode 4.0 Test 3.0 Pos 3.0 Lab 4.0; 
	infile datalines delimiter='/'; 
	input Weekcode Test Pos Lab;  
	datalines;                     
2101/ 0/ 0/ 0/
2102/ 8/ 3/ 256/
2103/ 3/ 1/ 619/
2104/ 0/ 0/ 0/
2105/ 0/ 0/ 0/
2106/ 5/ 2/ 2066/
2107/ 3/ 0/ 256/
2108/ 0/ 0/ 0/
2109/ 0/ 0/ 0/
2110/ 7/ 6/ 619/
2111/ 0/ 0/ 0/
2112/ 0/ 0/ 0/
2113/ 0/ 0/ 0/
2114/ 0/ 0/ 0/
2115/ 0/ 0/ 0/
;  
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star
Create a data set with all zeros:

data zero ;
Test = 0;
Pos = 0;
Lab = 0;
do weekcode = 2101 to 2115;
output;
end ;
run;

Then merge, making sure to mention the zeros data set first:

data want;
merge zero have;
by weekcode;
run;

View solution in original post

1 REPLY 1
Astounding
PROC Star
Create a data set with all zeros:

data zero ;
Test = 0;
Pos = 0;
Lab = 0;
do weekcode = 2101 to 2115;
output;
end ;
run;

Then merge, making sure to mention the zeros data set first:

data want;
merge zero have;
by weekcode;
run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 156 views
  • 0 likes
  • 2 in conversation