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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 143 views
  • 0 likes
  • 2 in conversation