BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tinghlin
Fluorite | Level 6

the original excel data is as follows:

tinghlin_0-1602214736937.png

Is it Possible to use proc import or other methods to import this filw?

i want the imported data as follows:

tinghlin_0-1602215188737.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jimbarbour
Meteorite | Level 14

@tinghlin,

 

It takes a bit of coding, but you can definitely do that.  Here are the results, and below the results is the SAS code.

 

Jim

 

jimbarbour_0-1602220479094.png

 

LIBNAME	School01	XLSX	"&Path\SampleData\Vertical_Merged_Cells.xlsx";

DATA	Class_Data;
	DROP	_:;

	SET	School01.Class_Data;

	LENGTH	_Prior_Code			$5;

	RETAIN	_Prior_ID			0;
	RETAIN	_Prior_Year			0;
	RETAIN	_Prior_SMTR			0;
	RETAIN	_Prior_Code			' ';
	RETAIN	_Prior_NStudent		0;
	RETAIN	_Prior_Proportion	0;

	IF	MISSING(ID)					THEN
		ID				=	_Prior_ID;

	IF	MISSING(Year)				THEN
		Year			=	_Prior_Year;

	IF	MISSING(SMTR)				THEN
		SMTR			=	_Prior_SMTR;

	IF	MISSING(Code)				THEN
		Code			=	_Prior_Code;

	IF	MISSING(NStudent)			THEN
		NStudent		=	_Prior_NStudent;

	IF	MISSING(Proportion)			THEN
		Proportion		=	_Prior_Proportion;

	_Prior_ID			=	ID;
	_Prior_Year			=	Year;
	_Prior_SMTR			=	SMTR;
	_Prior_Code			=	Code;
	_Prior_NStudent		=	NStudent;
	_Prior_Proportion	=	Proportion;
RUN;

 

 

 

View solution in original post

1 REPLY 1
jimbarbour
Meteorite | Level 14

@tinghlin,

 

It takes a bit of coding, but you can definitely do that.  Here are the results, and below the results is the SAS code.

 

Jim

 

jimbarbour_0-1602220479094.png

 

LIBNAME	School01	XLSX	"&Path\SampleData\Vertical_Merged_Cells.xlsx";

DATA	Class_Data;
	DROP	_:;

	SET	School01.Class_Data;

	LENGTH	_Prior_Code			$5;

	RETAIN	_Prior_ID			0;
	RETAIN	_Prior_Year			0;
	RETAIN	_Prior_SMTR			0;
	RETAIN	_Prior_Code			' ';
	RETAIN	_Prior_NStudent		0;
	RETAIN	_Prior_Proportion	0;

	IF	MISSING(ID)					THEN
		ID				=	_Prior_ID;

	IF	MISSING(Year)				THEN
		Year			=	_Prior_Year;

	IF	MISSING(SMTR)				THEN
		SMTR			=	_Prior_SMTR;

	IF	MISSING(Code)				THEN
		Code			=	_Prior_Code;

	IF	MISSING(NStudent)			THEN
		NStudent		=	_Prior_NStudent;

	IF	MISSING(Proportion)			THEN
		Proportion		=	_Prior_Proportion;

	_Prior_ID			=	ID;
	_Prior_Year			=	Year;
	_Prior_SMTR			=	SMTR;
	_Prior_Code			=	Code;
	_Prior_NStudent		=	NStudent;
	_Prior_Proportion	=	Proportion;
RUN;

 

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 670 views
  • 1 like
  • 2 in conversation